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