Pepper_47_C++_interfaces
url_request_info.cc
Go to the documentation of this file.
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include "ppapi/cpp/file_ref.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h"
11 
12 namespace pp {
13 
14 namespace {
15 
16 template <> const char* interface_name<PPB_URLRequestInfo_1_0>() {
17  return PPB_URLREQUESTINFO_INTERFACE_1_0;
18 }
19 
20 } // namespace
21 
23  if (!has_interface<PPB_URLRequestInfo_1_0>())
24  return;
26  get_interface<PPB_URLRequestInfo_1_0>()->Create(instance.pp_instance()));
27 }
28 
30  : Resource(other) {
31 }
32 
33 bool URLRequestInfo::SetProperty(PP_URLRequestProperty property,
34  const Var& value) {
35  if (!has_interface<PPB_URLRequestInfo_1_0>())
36  return false;
37  return PP_ToBool(get_interface<PPB_URLRequestInfo_1_0>()->SetProperty(
38  pp_resource(), property, value.pp_var()));
39 }
40 
41 bool URLRequestInfo::AppendDataToBody(const void* data, uint32_t len) {
42  if (!has_interface<PPB_URLRequestInfo_1_0>())
43  return false;
44  return PP_ToBool(get_interface<PPB_URLRequestInfo_1_0>()->AppendDataToBody(
45  pp_resource(), data, len));
46 }
47 
49  PP_Time expected_last_modified_time) {
50  if (!has_interface<PPB_URLRequestInfo_1_0>())
51  return false;
52  return PP_ToBool(
53  get_interface<PPB_URLRequestInfo_1_0>()->AppendFileToBody(
54  pp_resource(),
55  file_ref.pp_resource(),
56  0,
57  -1,
58  expected_last_modified_time));
59 }
60 
62  const FileRef& file_ref,
63  int64_t start_offset,
64  int64_t length,
65  PP_Time expected_last_modified_time) {
66  if (!has_interface<PPB_URLRequestInfo_1_0>())
67  return false;
68  return PP_ToBool(get_interface<PPB_URLRequestInfo_1_0>()->AppendFileToBody(
69  pp_resource(),
70  file_ref.pp_resource(),
71  start_offset,
72  length,
73  expected_last_modified_time));
74 }
75 
76 } // namespace pp
void PassRefFromConstructor(PP_Resource resource)
Definition: resource.cc:50
bool AppendFileRangeToBody(const FileRef &file_ref, int64_t start_offset, int64_t length, PP_Time expected_last_modified_time=0)
const PP_Var & pp_var() const
Definition: var.h:226
bool AppendFileToBody(const FileRef &file_ref, PP_Time expected_last_modified_time=0)
URLRequestInfo provides an API for creating and manipulating URL requests.
PP_Resource pp_resource() const
Definition: resource.h:47
bool AppendDataToBody(const void *data, uint32_t len)
A generic type used for passing data types between the module and the page.
Definition: var.h:21
PP_Instance pp_instance() const
bool SetProperty(PP_URLRequestProperty property, const Var &value)
A reference counted module resource.
Definition: resource.h:20