OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 16 matching lines...) Expand all Loading... |
27 #include "base/memory/ref_counted.h" | 27 #include "base/memory/ref_counted.h" |
28 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
29 #include "base/platform_file.h" | 29 #include "base/platform_file.h" |
30 #include "base/time.h" | 30 #include "base/time.h" |
31 #include "base/values.h" | 31 #include "base/values.h" |
32 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
33 #include "net/base/host_port_pair.h" | 33 #include "net/base/host_port_pair.h" |
34 #include "net/url_request/url_request_status.h" | 34 #include "net/url_request/url_request_status.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
36 #include "webkit/glue/resource_type.h" | 36 #include "webkit/glue/resource_type.h" |
| 37 #include "webkit/glue/webkit_glue_export.h" |
37 | 38 |
38 namespace net { | 39 namespace net { |
39 class HttpResponseHeaders; | 40 class HttpResponseHeaders; |
40 } | 41 } |
41 | 42 |
42 namespace webkit_glue { | 43 namespace webkit_glue { |
43 | 44 |
44 // Structure containing timing information for the request. It addresses | 45 // Structure containing timing information for the request. It addresses |
45 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec | 46 // http://groups.google.com/group/http-archive-specification/web/har-1-1-spec |
46 // and http://dev.w3.org/2006/webapi/WebTiming/ needs. | 47 // and http://dev.w3.org/2006/webapi/WebTiming/ needs. |
47 // | 48 // |
48 // All the values for starts and ends are given in milliseconds and are | 49 // All the values for starts and ends are given in milliseconds and are |
49 // offsets with respect to the given base time. | 50 // offsets with respect to the given base time. |
50 struct ResourceLoadTimingInfo { | 51 struct ResourceLoadTimingInfo { |
51 ResourceLoadTimingInfo(); | 52 WEBKIT_GLUE_EXPORT ResourceLoadTimingInfo(); |
52 ~ResourceLoadTimingInfo(); | 53 WEBKIT_GLUE_EXPORT ~ResourceLoadTimingInfo(); |
53 | 54 |
54 // All the values in this struct are given as offsets in milliseconds wrt | 55 // All the values in this struct are given as offsets in milliseconds wrt |
55 // this base time. | 56 // this base time. |
56 base::Time base_time; | 57 base::Time base_time; |
57 | 58 |
58 // The time that proxy processing started. For requests with no proxy phase, | 59 // The time that proxy processing started. For requests with no proxy phase, |
59 // this time is -1. | 60 // this time is -1. |
60 int32 proxy_start; | 61 int32 proxy_start; |
61 | 62 |
62 // The time that proxy processing ended. For reused sockets this time | 63 // The time that proxy processing ended. For reused sockets this time |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 // The time at which receiving HTTP headers ended. For non-HTTP requests | 98 // The time at which receiving HTTP headers ended. For non-HTTP requests |
98 // this is 0. | 99 // this is 0. |
99 int32 receive_headers_end; | 100 int32 receive_headers_end; |
100 }; | 101 }; |
101 | 102 |
102 struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> { | 103 struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> { |
103 typedef std::vector<std::pair<std::string, std::string> > | 104 typedef std::vector<std::pair<std::string, std::string> > |
104 HeadersVector; | 105 HeadersVector; |
105 | 106 |
106 ResourceDevToolsInfo(); | 107 WEBKIT_GLUE_EXPORT ResourceDevToolsInfo(); |
107 ~ResourceDevToolsInfo(); | 108 WEBKIT_GLUE_EXPORT ~ResourceDevToolsInfo(); |
108 | 109 |
109 int32 http_status_code; | 110 int32 http_status_code; |
110 std::string http_status_text; | 111 std::string http_status_text; |
111 HeadersVector request_headers; | 112 HeadersVector request_headers; |
112 HeadersVector response_headers; | 113 HeadersVector response_headers; |
113 std::string request_headers_text; | 114 std::string request_headers_text; |
114 std::string response_headers_text; | 115 std::string response_headers_text; |
115 }; | 116 }; |
116 | 117 |
117 struct ResourceResponseInfo { | 118 struct ResourceResponseInfo { |
118 ResourceResponseInfo(); | 119 WEBKIT_GLUE_EXPORT ResourceResponseInfo(); |
119 ~ResourceResponseInfo(); | 120 WEBKIT_GLUE_EXPORT ~ResourceResponseInfo(); |
120 | 121 |
121 // The time at which the request was made that resulted in this response. | 122 // The time at which the request was made that resulted in this response. |
122 // For cached responses, this time could be "far" in the past. | 123 // For cached responses, this time could be "far" in the past. |
123 base::Time request_time; | 124 base::Time request_time; |
124 | 125 |
125 // The time at which the response headers were received. For cached | 126 // The time at which the response headers were received. For cached |
126 // responses, this time could be "far" in the past. | 127 // responses, this time could be "far" in the past. |
127 base::Time response_time; | 128 base::Time response_time; |
128 | 129 |
129 // The response headers or NULL if the URL type does not support headers. | 130 // The response headers or NULL if the URL type does not support headers. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 bool was_fetched_via_proxy; | 192 bool was_fetched_via_proxy; |
192 | 193 |
193 // Remote address of the socket which fetched this resource. | 194 // Remote address of the socket which fetched this resource. |
194 net::HostPortPair socket_address; | 195 net::HostPortPair socket_address; |
195 }; | 196 }; |
196 | 197 |
197 class ResourceLoaderBridge { | 198 class ResourceLoaderBridge { |
198 public: | 199 public: |
199 // Structure used when calling | 200 // Structure used when calling |
200 // WebKitPlatformSupportImpl::CreateResourceLoader(). | 201 // WebKitPlatformSupportImpl::CreateResourceLoader(). |
201 struct RequestInfo { | 202 struct WEBKIT_GLUE_EXPORT RequestInfo { |
202 RequestInfo(); | 203 RequestInfo(); |
203 ~RequestInfo(); | 204 ~RequestInfo(); |
204 | 205 |
205 // HTTP-style method name (e.g., "GET" or "POST"). | 206 // HTTP-style method name (e.g., "GET" or "POST"). |
206 std::string method; | 207 std::string method; |
207 | 208 |
208 // Absolute URL encoded in ASCII per the rules of RFC-2396. | 209 // Absolute URL encoded in ASCII per the rules of RFC-2396. |
209 GURL url; | 210 GURL url; |
210 | 211 |
211 // URL of the document in the top-level window, which may be checked by the | 212 // URL of the document in the top-level window, which may be checked by the |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 325 |
325 // Called when the response is complete. This method signals completion of | 326 // Called when the response is complete. This method signals completion of |
326 // the resource load.ff | 327 // the resource load.ff |
327 virtual void OnCompletedRequest(const net::URLRequestStatus& status, | 328 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
328 const std::string& security_info, | 329 const std::string& security_info, |
329 const base::Time& completion_time) = 0; | 330 const base::Time& completion_time) = 0; |
330 }; | 331 }; |
331 | 332 |
332 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but | 333 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but |
333 // anybody can delete at any time, INCLUDING during processing of callbacks. | 334 // anybody can delete at any time, INCLUDING during processing of callbacks. |
334 virtual ~ResourceLoaderBridge(); | 335 WEBKIT_GLUE_EXPORT virtual ~ResourceLoaderBridge(); |
335 | 336 |
336 // Call this method before calling Start() to append a chunk of binary data | 337 // Call this method before calling Start() to append a chunk of binary data |
337 // to the request body. May only be used with HTTP(S) POST requests. | 338 // to the request body. May only be used with HTTP(S) POST requests. |
338 virtual void AppendDataToUpload(const char* data, int data_len) = 0; | 339 virtual void AppendDataToUpload(const char* data, int data_len) = 0; |
339 | 340 |
340 // Call this method before calling Start() to append the contents of a file | 341 // Call this method before calling Start() to append the contents of a file |
341 // to the request body. May only be used with HTTP(S) POST requests. | 342 // to the request body. May only be used with HTTP(S) POST requests. |
342 void AppendFileToUpload(const FilePath& file_path) { | 343 void AppendFileToUpload(const FilePath& file_path) { |
343 AppendFileRangeToUpload(file_path, 0, kuint64max, base::Time()); | 344 AppendFileRangeToUpload(file_path, 0, kuint64max, base::Time()); |
344 } | 345 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 386 |
386 // When loader is transferred from one page to another, the IPC routing id | 387 // When loader is transferred from one page to another, the IPC routing id |
387 // can change (they are associated with pages). | 388 // can change (they are associated with pages). |
388 virtual void UpdateRoutingId(int new_routing_id) = 0; | 389 virtual void UpdateRoutingId(int new_routing_id) = 0; |
389 | 390 |
390 protected: | 391 protected: |
391 // Construction must go through | 392 // Construction must go through |
392 // WebKitPlatformSupportImpl::CreateResourceLoader() | 393 // WebKitPlatformSupportImpl::CreateResourceLoader() |
393 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload | 394 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload |
394 // methods may be called to construct the body of the request. | 395 // methods may be called to construct the body of the request. |
395 ResourceLoaderBridge(); | 396 WEBKIT_GLUE_EXPORT ResourceLoaderBridge(); |
396 | 397 |
397 private: | 398 private: |
398 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); | 399 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); |
399 }; | 400 }; |
400 | 401 |
401 } // namespace webkit_glue | 402 } // namespace webkit_glue |
402 | 403 |
403 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 404 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ |
OLD | NEW |