Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Side by Side Diff: ppapi/shared_impl/url_request_info_impl.h

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

Powered by Google App Engine
This is Rietveld 408576698