OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ |
6 #define COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ | 6 #define COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/time/time.h" |
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 13 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
15 namespace web_view { | 16 namespace web_view { |
16 | 17 |
17 // This class caches data associated with a mojo::URLRequest and vends copies | 18 // This class caches data associated with a mojo::URLRequest and vends copies |
18 // of the request for the WebView system. Copies are used for repeated | 19 // of the request for the WebView system. Copies are used for repeated |
19 // navigations, but URLRequest structs are not copyable, as they contain | 20 // navigations, but URLRequest structs are not copyable, as they contain |
20 // handles to transfer large amounts of data between processes, so we | 21 // handles to transfer large amounts of data between processes, so we |
21 // immediately read the data from pipes and keep a copy here. | 22 // immediately read the data from pipes and keep a copy here. |
22 class URLRequestCloneable { | 23 class URLRequestCloneable { |
23 public: | 24 public: |
24 explicit URLRequestCloneable(mojo::URLRequestPtr original_request); | 25 explicit URLRequestCloneable(mojo::URLRequestPtr original_request); |
25 explicit URLRequestCloneable(const GURL& raw_url); | 26 explicit URLRequestCloneable(const GURL& raw_url); |
26 ~URLRequestCloneable(); | 27 ~URLRequestCloneable(); |
27 | 28 |
28 // Creates a new URLRequest. | 29 // Creates a new URLRequest. |
29 mojo::URLRequestPtr Clone() const; | 30 mojo::URLRequestPtr Clone() const; |
30 | 31 |
| 32 base::TimeTicks originating_time() const { return originating_time_; } |
| 33 void set_originating_time(base::TimeTicks value) { |
| 34 originating_time_ = value; |
| 35 } |
| 36 |
31 private: | 37 private: |
32 // All of these are straight from mojo::URLRequest. | 38 // All of these are straight from mojo::URLRequest. |
33 mojo::String url_; | 39 mojo::String url_; |
34 mojo::String method_; | 40 mojo::String method_; |
35 mojo::Array<mojo::HttpHeaderPtr> headers_; | 41 mojo::Array<mojo::HttpHeaderPtr> headers_; |
36 uint32_t response_body_buffer_size_; | 42 uint32_t response_body_buffer_size_; |
37 bool auto_follow_redirects_; | 43 bool auto_follow_redirects_; |
38 bool bypass_cache_; | 44 bool bypass_cache_; |
39 | 45 |
40 // Whether the body mojo array in the |original_request| was null. We keep | 46 // Whether the body mojo array in the |original_request| was null. We keep |
41 // track of this so we can differentiate between null arrays and empty | 47 // track of this so we can differentiate between null arrays and empty |
42 // arrays. | 48 // arrays. |
43 bool original_body_null_; | 49 bool original_body_null_; |
44 | 50 |
45 // This is a serialized version of the data from mojo::URLRequest. We copy | 51 // This is a serialized version of the data from mojo::URLRequest. We copy |
46 // this data straight out of the data pipes, and then serve it any time that | 52 // this data straight out of the data pipes, and then serve it any time that |
47 // AsURLRequest() is called. | 53 // AsURLRequest() is called. |
48 std::vector<std::string> body_; | 54 std::vector<std::string> body_; |
49 | 55 |
| 56 base::TimeTicks originating_time_; |
| 57 |
50 DISALLOW_COPY_AND_ASSIGN(URLRequestCloneable); | 58 DISALLOW_COPY_AND_ASSIGN(URLRequestCloneable); |
51 }; | 59 }; |
52 | 60 |
53 } // namespace web_view | 61 } // namespace web_view |
54 | 62 |
55 #endif // COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ | 63 #endif // COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ |
OLD | NEW |