Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: components/web_view/url_request_cloneable.cc

Issue 1333173004: mandoline: Add back/forward support and UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/web_view/url_request_cloneable.h ('k') | components/web_view/web_view_apptest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "components/web_view/url_request_cloneable.h"
6
7 #include "base/logging.h"
8 #include "mojo/common/data_pipe_utils.h"
9
10 namespace web_view {
11
12 URLRequestCloneable::URLRequestCloneable(mojo::URLRequestPtr original_request)
13 : url_(original_request->url),
14 method_(original_request->method),
15 headers_(original_request->headers.Pass()),
16 response_body_buffer_size_(original_request->response_body_buffer_size),
17 auto_follow_redirects_(original_request->auto_follow_redirects),
18 bypass_cache_(original_request->bypass_cache),
19 original_body_null_(original_request->body.is_null()),
20 body_(original_request->body.size()) {
21 // TODO(erg): Maybe we can do some sort of async copy here?
22 for (size_t i = 0; i < original_request->body.size(); ++i) {
23 mojo::common::BlockingCopyToString(original_request->body[i].Pass(),
24 &body_[i]);
25 }
26 }
27
28 URLRequestCloneable::~URLRequestCloneable() {}
29
30 mojo::URLRequestPtr URLRequestCloneable::Clone() const {
31 mojo::URLRequestPtr request = mojo::URLRequest::New();
32 request->url = url_;
33 request->method = method_;
34 request->headers = headers_.Clone();
35 request->response_body_buffer_size = response_body_buffer_size_;
36 request->auto_follow_redirects = auto_follow_redirects_;
37 request->bypass_cache = bypass_cache_;
38
39 if (!original_body_null_) {
40 request->body =
41 mojo::Array<mojo::ScopedDataPipeConsumerHandle>(body_.size());
42 for (size_t i = 0; i < body_.size(); ++i) {
43 uint32_t num_bytes = static_cast<uint32_t>(body_[i].size());
44 MojoCreateDataPipeOptions options;
45 options.struct_size = sizeof(MojoCreateDataPipeOptions);
46 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
47 options.element_num_bytes = 1;
48 options.capacity_num_bytes = num_bytes;
49 mojo::DataPipe data_pipe(options);
50 request->body[i] = data_pipe.consumer_handle.Pass();
51 WriteDataRaw(data_pipe.producer_handle.get(), body_[i].data(), &num_bytes,
52 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
53 DCHECK_EQ(num_bytes, body_[i].size());
54 }
55 }
56
57 return request.Pass();
58 }
59
60 } // namespace web_view
OLDNEW
« no previous file with comments | « components/web_view/url_request_cloneable.h ('k') | components/web_view/web_view_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698