| 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 void set_originating_time(base::TimeTicks value) { |
| 33 originating_time_ = value; |
| 34 } |
| 35 |
| 31 private: | 36 private: |
| 32 // All of these are straight from mojo::URLRequest. | 37 // All of these are straight from mojo::URLRequest. |
| 33 mojo::String url_; | 38 mojo::String url_; |
| 34 mojo::String method_; | 39 mojo::String method_; |
| 35 mojo::Array<mojo::HttpHeaderPtr> headers_; | 40 mojo::Array<mojo::HttpHeaderPtr> headers_; |
| 36 uint32_t response_body_buffer_size_; | 41 uint32_t response_body_buffer_size_; |
| 37 bool auto_follow_redirects_; | 42 bool auto_follow_redirects_; |
| 38 bool bypass_cache_; | 43 bool bypass_cache_; |
| 39 | 44 |
| 40 // Whether the body mojo array in the |original_request| was null. We keep | 45 // 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 | 46 // track of this so we can differentiate between null arrays and empty |
| 42 // arrays. | 47 // arrays. |
| 43 bool original_body_null_; | 48 bool original_body_null_; |
| 44 | 49 |
| 45 // This is a serialized version of the data from mojo::URLRequest. We copy | 50 // 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 | 51 // this data straight out of the data pipes, and then serve it any time that |
| 47 // AsURLRequest() is called. | 52 // AsURLRequest() is called. |
| 48 std::vector<std::string> body_; | 53 std::vector<std::string> body_; |
| 49 | 54 |
| 55 base::TimeTicks originating_time_; |
| 56 |
| 50 DISALLOW_COPY_AND_ASSIGN(URLRequestCloneable); | 57 DISALLOW_COPY_AND_ASSIGN(URLRequestCloneable); |
| 51 }; | 58 }; |
| 52 | 59 |
| 53 } // namespace web_view | 60 } // namespace web_view |
| 54 | 61 |
| 55 #endif // COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ | 62 #endif // COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_ |
| OLD | NEW |