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.
5 #ifndef COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_
6 #define COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_
11 #include "base/basictypes.h"
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
16 // This class caches data associated with a mojo::URLRequest and vends copies
17 // of the request for the WebView system. Copies are used for repeated
18 // navigations, but URLRequest structs are not copyable, as they contain
19 // handles to transfer large amounts of data between processes, so we
20 // immediately read the data from pipes and keep a copy here.
21 class URLRequestCloneable
{
23 explicit URLRequestCloneable(mojo::URLRequestPtr original_request
);
24 ~URLRequestCloneable();
26 // Creates a new URLRequest.
27 mojo::URLRequestPtr
Clone() const;
30 // All of these are straight from mojo::URLRequest.
33 mojo::Array
<mojo::HttpHeaderPtr
> headers_
;
34 uint32_t response_body_buffer_size_
;
35 bool auto_follow_redirects_
;
38 // Whether the body mojo array in the |original_request| was null. We keep
39 // track of this so we can differentiate between null arrays and empty
41 bool original_body_null_
;
43 // This is a serialized version of the data from mojo::URLRequest. We copy
44 // this data straight out of the data pipes, and then serve it any time that
45 // AsURLRequest() is called.
46 std::vector
<std::string
> body_
;
48 DISALLOW_COPY_AND_ASSIGN(URLRequestCloneable
);
51 } // namespace web_view
53 #endif // COMPONENTS_WEB_VIEW_URL_REQUEST_CLONEABLE_H_