OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 | |
5 #ifndef PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ | |
6 #define PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "ppapi/shared_impl/resource.h" | |
13 #include "ppapi/thunk/ppb_url_request_info_api.h" | |
14 | |
15 namespace ppapi { | |
16 | |
17 struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { | |
18 struct PPAPI_SHARED_EXPORT BodyItem { | |
19 BodyItem(); | |
20 explicit BodyItem(const std::string& data); | |
21 BodyItem(Resource* file_ref, | |
22 int64_t start_offset, | |
23 int64_t number_of_bytes, | |
24 PP_Time expected_last_modified_time); | |
25 | |
26 // Set if the input is a file, false means the |data| is valid. | |
27 bool is_file; | |
28 | |
29 std::string data; | |
30 | |
31 // Is is_file is set, these variables are set. Note that the resource | |
32 // may still be NULL in some cases, such as deserialization errors. | |
33 // | |
34 // This is a bit tricky. In the plugin side of the proxy, both the file ref | |
35 // and the file_ref_host_resource will be set and valid. The scoped_ptr | |
36 // ensures that the resource is alive for as long as the BodyItem is. | |
37 // | |
38 // When we deserialize this in the renderer, only the | |
39 // file_ref_host_resource's are serialized over IPC. The file_refs won't be | |
40 // valid until the host resources are converted to Resource pointers in the | |
41 // PPB_URLRequestInfo_Impl. | |
42 scoped_refptr<Resource> file_ref; | |
43 HostResource file_ref_host_resource; | |
44 | |
45 int64_t start_offset; | |
46 int64_t number_of_bytes; | |
47 PP_Time expected_last_modified_time; | |
48 | |
49 // If you add more stuff here, be sure to modify the serialization rules in | |
50 // ppapi_messages.h | |
51 }; | |
52 | |
53 PPB_URLRequestInfo_Data(); | |
54 ~PPB_URLRequestInfo_Data(); | |
55 | |
56 std::string url; | |
57 std::string method; | |
58 std::string headers; | |
59 | |
60 bool stream_to_file; | |
61 bool follow_redirects; | |
62 bool record_download_progress; | |
63 bool record_upload_progress; | |
64 | |
65 // |has_custom_referrer_url| is set to false if a custom referrer hasn't been | |
66 // set (or has been set to an Undefined Var) and the default referrer should | |
67 // be used. (Setting the custom referrer to an empty string indicates that no | |
68 // referrer header should be generated.) | |
69 bool has_custom_referrer_url; | |
70 std::string custom_referrer_url; | |
71 | |
72 bool allow_cross_origin_requests; | |
73 bool allow_credentials; | |
74 | |
75 // Similar to the custom referrer (above), but for custom content transfer | |
76 // encoding. | |
77 bool has_custom_content_transfer_encoding; | |
78 std::string custom_content_transfer_encoding; | |
79 | |
80 int32_t prefetch_buffer_upper_threshold; | |
81 int32_t prefetch_buffer_lower_threshold; | |
82 | |
83 std::vector<BodyItem> body; | |
84 | |
85 // If you add more stuff here, be sure to modify the serialization rules in | |
86 // ppapi_messages.h | |
87 }; | |
88 | |
89 class PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Shared | |
90 : public ::ppapi::Resource, | |
91 public ::ppapi::thunk::PPB_URLRequestInfo_API { | |
92 public: | |
93 // This constructor initializes the object as a proxy object with the given | |
94 // host resource. | |
95 PPB_URLRequestInfo_Shared(const HostResource& host_resource, | |
96 const PPB_URLRequestInfo_Data& data); | |
97 | |
98 ~PPB_URLRequestInfo_Shared(); | |
99 | |
100 // Resource overrides. | |
101 virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; | |
102 | |
103 // PPB_URLRequestInfo_API implementation. | |
104 virtual PP_Bool SetProperty(PP_URLRequestProperty property, | |
105 PP_Var var) OVERRIDE; | |
106 virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; | |
107 virtual PP_Bool AppendFileToBody( | |
108 PP_Resource file_ref, | |
109 int64_t start_offset, | |
110 int64_t number_of_bytes, | |
111 PP_Time expected_last_modified_time) OVERRIDE; | |
112 virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE; | |
113 | |
114 protected: | |
115 // Constructor used by the webkit implementation. | |
116 PPB_URLRequestInfo_Shared(PP_Instance instance, | |
117 const PPB_URLRequestInfo_Data& data); | |
118 | |
119 bool SetUndefinedProperty(PP_URLRequestProperty property); | |
120 bool SetBooleanProperty(PP_URLRequestProperty property, bool value); | |
121 bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); | |
122 bool SetStringProperty(PP_URLRequestProperty property, | |
123 const std::string& value); | |
124 | |
125 const PPB_URLRequestInfo_Data& data() const { return data_; } | |
126 PPB_URLRequestInfo_Data& data() { return data_; } | |
127 | |
128 private: | |
129 PPB_URLRequestInfo_Data data_; | |
130 | |
131 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_URLRequestInfo_Shared); | |
132 }; | |
133 | |
134 } // namespace ppapi | |
135 | |
136 #endif // PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ | |
OLD | NEW |