OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // The intent of this file is to provide a type-neutral abstraction between | 5 // The intent of this file is to provide a type-neutral abstraction between |
6 // Chrome and WebKit for resource loading. This pure-virtual interface is | 6 // Chrome and WebKit for resource loading. This pure-virtual interface is |
7 // implemented by the embedder. | 7 // implemented by the embedder. |
8 // | 8 // |
9 // One of these objects will be created by WebKit for each request. WebKit | 9 // One of these objects will be created by WebKit for each request. WebKit |
10 // will own the pointer to the bridge, and will delete it when the request is | 10 // will own the pointer to the bridge, and will delete it when the request is |
11 // no longer needed. | 11 // no longer needed. |
12 // | 12 // |
13 // In turn, the bridge's owner on the WebKit end will implement the Peer | 13 // In turn, the bridge's owner on the WebKit end will implement the Peer |
14 // interface, which we will use to communicate notifications back. | 14 // interface, which we will use to communicate notifications back. |
15 | 15 |
16 #ifndef WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 16 #ifndef WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ |
17 #define WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 17 #define WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ |
18 | 18 |
19 #include <utility> | 19 #include <utility> |
20 | 20 |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #if defined(OS_POSIX) | 22 #if defined(OS_POSIX) |
23 #include "base/file_descriptor_posix.h" | 23 #include "base/file_descriptor_posix.h" |
24 #endif | 24 #endif |
25 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
26 #include "base/platform_file.h" | 26 #include "base/platform_file.h" |
27 #include "base/values.h" | 27 #include "base/values.h" |
28 #include "net/base/request_priority.h" | 28 #include "net/base/request_priority.h" |
29 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 29 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
30 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
31 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 32 #include "webkit/child/webkit_child_export.h" |
32 #include "webkit/common/resource_response_info.h" | 33 #include "webkit/common/resource_response_info.h" |
33 #include "webkit/glue/resource_type.h" | 34 #include "webkit/common/resource_type.h" |
34 #include "webkit/glue/webkit_glue_export.h" | |
35 | 35 |
36 namespace webkit_glue { | 36 namespace webkit_glue { |
37 class ResourceRequestBody; | 37 class ResourceRequestBody; |
38 | 38 |
39 class ResourceLoaderBridge { | 39 class ResourceLoaderBridge { |
40 public: | 40 public: |
41 // Structure used when calling | 41 // Structure used when calling |
42 // WebKitPlatformSupportImpl::CreateResourceLoader(). | 42 // WebKitPlatformSupportImpl::CreateResourceLoader(). |
43 struct WEBKIT_GLUE_EXPORT RequestInfo { | 43 struct WEBKIT_CHILD_EXPORT RequestInfo { |
44 RequestInfo(); | 44 RequestInfo(); |
45 ~RequestInfo(); | 45 ~RequestInfo(); |
46 | 46 |
47 // HTTP-style method name (e.g., "GET" or "POST"). | 47 // HTTP-style method name (e.g., "GET" or "POST"). |
48 std::string method; | 48 std::string method; |
49 | 49 |
50 // Absolute URL encoded in ASCII per the rules of RFC-2396. | 50 // Absolute URL encoded in ASCII per the rules of RFC-2396. |
51 GURL url; | 51 GURL url; |
52 | 52 |
53 // URL of the document in the top-level window, which may be checked by the | 53 // URL of the document in the top-level window, which may be checked by the |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Extra data associated with this request. We do not own this pointer. | 99 // Extra data associated with this request. We do not own this pointer. |
100 WebKit::WebURLRequest::ExtraData* extra_data; | 100 WebKit::WebURLRequest::ExtraData* extra_data; |
101 | 101 |
102 private: | 102 private: |
103 DISALLOW_COPY_AND_ASSIGN(RequestInfo); | 103 DISALLOW_COPY_AND_ASSIGN(RequestInfo); |
104 }; | 104 }; |
105 | 105 |
106 // See the SyncLoad method declared below. (The name of this struct is not | 106 // See the SyncLoad method declared below. (The name of this struct is not |
107 // suffixed with "Info" because it also contains the response data.) | 107 // suffixed with "Info" because it also contains the response data.) |
108 struct SyncLoadResponse : ResourceResponseInfo { | 108 struct SyncLoadResponse : ResourceResponseInfo { |
109 SyncLoadResponse(); | 109 WEBKIT_CHILD_EXPORT SyncLoadResponse(); |
110 ~SyncLoadResponse(); | 110 WEBKIT_CHILD_EXPORT ~SyncLoadResponse(); |
111 | 111 |
112 // The response error code. | 112 // The response error code. |
113 int error_code; | 113 int error_code; |
114 | 114 |
115 // The final URL of the response. This may differ from the request URL in | 115 // The final URL of the response. This may differ from the request URL in |
116 // the case of a server redirect. | 116 // the case of a server redirect. |
117 GURL url; | 117 GURL url; |
118 | 118 |
119 // The response data. | 119 // The response data. |
120 std::string data; | 120 std::string data; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bool was_ignored_by_handler, | 175 bool was_ignored_by_handler, |
176 const std::string& security_info, | 176 const std::string& security_info, |
177 const base::TimeTicks& completion_time) = 0; | 177 const base::TimeTicks& completion_time) = 0; |
178 | 178 |
179 protected: | 179 protected: |
180 virtual ~Peer() {} | 180 virtual ~Peer() {} |
181 }; | 181 }; |
182 | 182 |
183 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but | 183 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but |
184 // anybody can delete at any time, INCLUDING during processing of callbacks. | 184 // anybody can delete at any time, INCLUDING during processing of callbacks. |
185 WEBKIT_GLUE_EXPORT virtual ~ResourceLoaderBridge(); | 185 WEBKIT_CHILD_EXPORT virtual ~ResourceLoaderBridge(); |
186 | 186 |
187 // Call this method before calling Start() to set the request body. | 187 // Call this method before calling Start() to set the request body. |
188 // May only be used with HTTP(S) POST requests. | 188 // May only be used with HTTP(S) POST requests. |
189 virtual void SetRequestBody(ResourceRequestBody* request_body) = 0; | 189 virtual void SetRequestBody(ResourceRequestBody* request_body) = 0; |
190 | 190 |
191 // Call this method to initiate the request. If this method succeeds, then | 191 // Call this method to initiate the request. If this method succeeds, then |
192 // the peer's methods will be called asynchronously to report various events. | 192 // the peer's methods will be called asynchronously to report various events. |
193 virtual bool Start(Peer* peer) = 0; | 193 virtual bool Start(Peer* peer) = 0; |
194 | 194 |
195 // Call this method to cancel a request that is in progress. This method | 195 // Call this method to cancel a request that is in progress. This method |
(...skipping 18 matching lines...) Expand all Loading... |
214 // use this if you really need it! There is also no way for the caller to | 214 // use this if you really need it! There is also no way for the caller to |
215 // interrupt this method. Errors are reported via the status field of the | 215 // interrupt this method. Errors are reported via the status field of the |
216 // response parameter. | 216 // response parameter. |
217 virtual void SyncLoad(SyncLoadResponse* response) = 0; | 217 virtual void SyncLoad(SyncLoadResponse* response) = 0; |
218 | 218 |
219 protected: | 219 protected: |
220 // Construction must go through | 220 // Construction must go through |
221 // WebKitPlatformSupportImpl::CreateResourceLoader() | 221 // WebKitPlatformSupportImpl::CreateResourceLoader() |
222 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload | 222 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload |
223 // methods may be called to construct the body of the request. | 223 // methods may be called to construct the body of the request. |
224 WEBKIT_GLUE_EXPORT ResourceLoaderBridge(); | 224 WEBKIT_CHILD_EXPORT ResourceLoaderBridge(); |
225 | 225 |
226 private: | 226 private: |
227 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); | 227 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); |
228 }; | 228 }; |
229 | 229 |
230 } // namespace webkit_glue | 230 } // namespace webkit_glue |
231 | 231 |
232 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 232 #endif // WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ |
OLD | NEW |