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_GLUE_RESOURCE_LOADER_BRIDGE_H_ |
17 #define WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 17 #define WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ |
18 | 18 |
19 #include <utility> | 19 #include <utility> |
20 #include <vector> | |
21 | 20 |
22 #include "build/build_config.h" | 21 #include "build/build_config.h" |
23 #if defined(OS_POSIX) | 22 #if defined(OS_POSIX) |
24 #include "base/file_descriptor_posix.h" | 23 #include "base/file_descriptor_posix.h" |
25 #endif | 24 #endif |
26 #include "base/files/file_path.h" | |
27 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
28 #include "base/platform_file.h" | 26 #include "base/platform_file.h" |
29 #include "base/time.h" | |
30 #include "base/values.h" | 27 #include "base/values.h" |
31 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
32 #include "net/base/host_port_pair.h" | |
33 #include "net/base/load_timing_info.h" | |
34 #include "net/base/request_priority.h" | 29 #include "net/base/request_priority.h" |
35 #include "net/http/http_response_info.h" | |
36 #include "net/url_request/url_request_status.h" | |
37 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 30 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
38 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 31 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 32 #include "webkit/common/resource_response_info.h" |
39 #include "webkit/glue/resource_type.h" | 33 #include "webkit/glue/resource_type.h" |
40 #include "webkit/glue/webkit_glue_export.h" | 34 #include "webkit/glue/webkit_glue_export.h" |
41 | 35 |
42 namespace net { | |
43 class HttpResponseHeaders; | |
44 } | |
45 | |
46 namespace webkit_glue { | 36 namespace webkit_glue { |
47 class ResourceRequestBody; | 37 class ResourceRequestBody; |
48 | 38 |
49 struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> { | |
50 typedef std::vector<std::pair<std::string, std::string> > | |
51 HeadersVector; | |
52 | |
53 WEBKIT_GLUE_EXPORT ResourceDevToolsInfo(); | |
54 | |
55 int32 http_status_code; | |
56 std::string http_status_text; | |
57 HeadersVector request_headers; | |
58 HeadersVector response_headers; | |
59 std::string request_headers_text; | |
60 std::string response_headers_text; | |
61 | |
62 private: | |
63 friend class base::RefCounted<ResourceDevToolsInfo>; | |
64 WEBKIT_GLUE_EXPORT ~ResourceDevToolsInfo(); | |
65 }; | |
66 | |
67 struct ResourceResponseInfo { | |
68 WEBKIT_GLUE_EXPORT ResourceResponseInfo(); | |
69 WEBKIT_GLUE_EXPORT ~ResourceResponseInfo(); | |
70 | |
71 // The time at which the request was made that resulted in this response. | |
72 // For cached responses, this time could be "far" in the past. | |
73 base::Time request_time; | |
74 | |
75 // The time at which the response headers were received. For cached | |
76 // responses, this time could be "far" in the past. | |
77 base::Time response_time; | |
78 | |
79 // The response headers or NULL if the URL type does not support headers. | |
80 scoped_refptr<net::HttpResponseHeaders> headers; | |
81 | |
82 // The mime type of the response. This may be a derived value. | |
83 std::string mime_type; | |
84 | |
85 // The character encoding of the response or none if not applicable to the | |
86 // response's mime type. This may be a derived value. | |
87 std::string charset; | |
88 | |
89 // An opaque string carrying security information pertaining to this | |
90 // response. This may include information about the SSL connection used. | |
91 std::string security_info; | |
92 | |
93 // Content length if available. -1 if not available | |
94 int64 content_length; | |
95 | |
96 // Length of the encoded data transferred over the network. In case there is | |
97 // no data, contains -1. | |
98 int64 encoded_data_length; | |
99 | |
100 // The appcache this response was loaded from, or kNoCacheId. | |
101 int64 appcache_id; | |
102 | |
103 // The manifest url of the appcache this response was loaded from. | |
104 // Note: this value is only populated for main resource requests. | |
105 GURL appcache_manifest_url; | |
106 | |
107 // Detailed timing information used by the WebTiming, HAR and Developer | |
108 // Tools. Includes socket ID and socket reuse information. | |
109 net::LoadTimingInfo load_timing; | |
110 | |
111 // Actual request and response headers, as obtained from the network stack. | |
112 // Only present if request had LOAD_REPORT_RAW_HEADERS in load_flags, and | |
113 // requesting renderer had CanReadRowCookies permission. | |
114 scoped_refptr<ResourceDevToolsInfo> devtools_info; | |
115 | |
116 // The path to a file that will contain the response body. It may only | |
117 // contain a portion of the response body at the time that the ResponseInfo | |
118 // becomes available. | |
119 base::FilePath download_file_path; | |
120 | |
121 // True if the response was delivered using SPDY. | |
122 bool was_fetched_via_spdy; | |
123 | |
124 // True if the response was delivered after NPN is negotiated. | |
125 bool was_npn_negotiated; | |
126 | |
127 // True if response could use alternate protocol. However, browser will | |
128 // ignore the alternate protocol when spdy is not enabled on browser side. | |
129 bool was_alternate_protocol_available; | |
130 | |
131 // Information about the type of connection used to fetch this response. | |
132 net::HttpResponseInfo::ConnectionInfo connection_info; | |
133 | |
134 // True if the response was fetched via an explicit proxy (as opposed to a | |
135 // transparent proxy). The proxy could be any type of proxy, HTTP or SOCKS. | |
136 // Note: we cannot tell if a transparent proxy may have been involved. | |
137 bool was_fetched_via_proxy; | |
138 | |
139 // NPN protocol negotiated with the server. | |
140 std::string npn_negotiated_protocol; | |
141 | |
142 // Remote address of the socket which fetched this resource. | |
143 net::HostPortPair socket_address; | |
144 }; | |
145 | |
146 class ResourceLoaderBridge { | 39 class ResourceLoaderBridge { |
147 public: | 40 public: |
148 // Structure used when calling | 41 // Structure used when calling |
149 // WebKitPlatformSupportImpl::CreateResourceLoader(). | 42 // WebKitPlatformSupportImpl::CreateResourceLoader(). |
150 struct WEBKIT_GLUE_EXPORT RequestInfo { | 43 struct WEBKIT_GLUE_EXPORT RequestInfo { |
151 RequestInfo(); | 44 RequestInfo(); |
152 ~RequestInfo(); | 45 ~RequestInfo(); |
153 | 46 |
154 // HTTP-style method name (e.g., "GET" or "POST"). | 47 // HTTP-style method name (e.g., "GET" or "POST"). |
155 std::string method; | 48 std::string method; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // methods may be called to construct the body of the request. | 223 // methods may be called to construct the body of the request. |
331 WEBKIT_GLUE_EXPORT ResourceLoaderBridge(); | 224 WEBKIT_GLUE_EXPORT ResourceLoaderBridge(); |
332 | 225 |
333 private: | 226 private: |
334 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); | 227 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); |
335 }; | 228 }; |
336 | 229 |
337 } // namespace webkit_glue | 230 } // namespace webkit_glue |
338 | 231 |
339 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ | 232 #endif // WEBKIT_GLUE_RESOURCE_LOADER_BRIDGE_H_ |
OLD | NEW |