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 |
(...skipping 10 matching lines...) Expand all Loading... |
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 "url/gurl.h" | 29 #include "url/gurl.h" |
30 #include "webkit/child/webkit_child_export.h" | 30 #include "webkit/child/webkit_child_export.h" |
31 #include "webkit/common/resource_response_info.h" | |
32 | 31 |
33 // TODO(pilgrim) remove this once resource loader is moved to content | 32 // TODO(pilgrim) remove this once resource loader is moved to content |
34 // http://crbug.com/338338 | 33 // http://crbug.com/338338 |
35 namespace content { | 34 namespace content { |
36 class ResourceRequestBody; | 35 class ResourceRequestBody; |
| 36 struct SyncLoadResponse; |
37 } | 37 } |
38 | 38 |
39 namespace webkit_glue { | 39 namespace webkit_glue { |
40 | 40 |
| 41 struct ResourceResponseInfo; |
| 42 |
41 class ResourceLoaderBridge { | 43 class ResourceLoaderBridge { |
42 public: | 44 public: |
43 // See the SyncLoad method declared below. (The name of this struct is not | |
44 // suffixed with "Info" because it also contains the response data.) | |
45 struct SyncLoadResponse : ResourceResponseInfo { | |
46 WEBKIT_CHILD_EXPORT SyncLoadResponse(); | |
47 WEBKIT_CHILD_EXPORT ~SyncLoadResponse(); | |
48 | |
49 // The response error code. | |
50 int error_code; | |
51 | |
52 // The final URL of the response. This may differ from the request URL in | |
53 // the case of a server redirect. | |
54 GURL url; | |
55 | |
56 // The response data. | |
57 std::string data; | |
58 }; | |
59 | |
60 // Generated by the bridge. This is implemented by our custom resource loader | 45 // Generated by the bridge. This is implemented by our custom resource loader |
61 // within webkit. The Peer and it's bridge should have identical lifetimes | 46 // within webkit. The Peer and it's bridge should have identical lifetimes |
62 // as they represent each end of a communication channel. | 47 // as they represent each end of a communication channel. |
63 // | 48 // |
64 // These callbacks mirror net::URLRequest::Delegate and the order and | 49 // These callbacks mirror net::URLRequest::Delegate and the order and |
65 // conditions in which they will be called are identical. See url_request.h | 50 // conditions in which they will be called are identical. See url_request.h |
66 // for more information. | 51 // for more information. |
67 class WEBKIT_CHILD_EXPORT Peer { | 52 class WEBKIT_CHILD_EXPORT Peer { |
68 public: | 53 public: |
69 // Called as upload progress is made. | 54 // Called as upload progress is made. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // call to the Start method. | 134 // call to the Start method. |
150 virtual void DidChangePriority(net::RequestPriority new_priority) = 0; | 135 virtual void DidChangePriority(net::RequestPriority new_priority) = 0; |
151 | 136 |
152 // Call this method to load the resource synchronously (i.e., in one shot). | 137 // Call this method to load the resource synchronously (i.e., in one shot). |
153 // This is an alternative to the Start method. Be warned that this method | 138 // This is an alternative to the Start method. Be warned that this method |
154 // will block the calling thread until the resource is fully downloaded or an | 139 // will block the calling thread until the resource is fully downloaded or an |
155 // error occurs. It could block the calling thread for a long time, so only | 140 // error occurs. It could block the calling thread for a long time, so only |
156 // use this if you really need it! There is also no way for the caller to | 141 // use this if you really need it! There is also no way for the caller to |
157 // interrupt this method. Errors are reported via the status field of the | 142 // interrupt this method. Errors are reported via the status field of the |
158 // response parameter. | 143 // response parameter. |
159 virtual void SyncLoad(SyncLoadResponse* response) = 0; | 144 virtual void SyncLoad(content::SyncLoadResponse* response) = 0; |
160 | 145 |
161 protected: | 146 protected: |
162 // Construction must go through | 147 // Construction must go through |
163 // WebKitPlatformSupportImpl::CreateResourceLoader() | 148 // WebKitPlatformSupportImpl::CreateResourceLoader() |
164 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload | 149 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload |
165 // methods may be called to construct the body of the request. | 150 // methods may be called to construct the body of the request. |
166 WEBKIT_CHILD_EXPORT ResourceLoaderBridge(); | 151 WEBKIT_CHILD_EXPORT ResourceLoaderBridge(); |
167 | 152 |
168 private: | 153 private: |
169 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); | 154 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); |
170 }; | 155 }; |
171 | 156 |
172 } // namespace webkit_glue | 157 } // namespace webkit_glue |
173 | 158 |
174 #endif // WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ | 159 #endif // WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ |
OLD | NEW |