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

Unified Diff: components/web_view/url_request_cloneable.cc

Issue 1326443006: mandoline: Add back/forward support and UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits and such. 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/web_view/url_request_cloneable.cc
diff --git a/components/web_view/url_request_cloneable.cc b/components/web_view/url_request_cloneable.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a56cb37dcb482252886ab001ce1b7ac0f4c2fa8
--- /dev/null
+++ b/components/web_view/url_request_cloneable.cc
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/web_view/url_request_cloneable.h"
+
+#include "base/logging.h"
+#include "mojo/common/data_pipe_utils.h"
+
+namespace web_view {
+
+URLRequestCloneable::URLRequestCloneable(mojo::URLRequestPtr original_request)
+ : url_(original_request->url),
+ method_(original_request->method),
+ headers_(original_request->headers.Pass()),
+ response_body_buffer_size_(original_request->response_body_buffer_size),
+ auto_follow_redirects_(original_request->auto_follow_redirects),
+ bypass_cache_(original_request->bypass_cache),
+ original_body_null_(original_request->body.is_null()),
+ body_(original_request->body.size()) {
+ // TODO(erg): Maybe we can do some sort of async copy here?
+ for (size_t i = 0; i < original_request->body.size(); ++i) {
+ mojo::common::BlockingCopyToString(original_request->body[i].Pass(),
+ &body_[i]);
+ }
+}
+
+URLRequestCloneable::~URLRequestCloneable() {}
+
+mojo::URLRequestPtr URLRequestCloneable::Clone() const {
+ mojo::URLRequestPtr request = mojo::URLRequest::New();
+ request->url = url_;
+ request->method = method_;
+ request->headers = headers_.Clone();
+ request->response_body_buffer_size = response_body_buffer_size_;
+ request->auto_follow_redirects = auto_follow_redirects_;
+ request->bypass_cache = bypass_cache_;
+
+ if (!original_body_null_) {
+ request->body =
+ mojo::Array<mojo::ScopedDataPipeConsumerHandle>(body_.size());
+ for (size_t i = 0; i < body_.size(); ++i) {
+ uint32_t num_bytes = body_[i].size();
+ MojoCreateDataPipeOptions options;
+ options.struct_size = sizeof(MojoCreateDataPipeOptions);
+ options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
+ options.element_num_bytes = 1;
+ options.capacity_num_bytes = num_bytes;
+ mojo::DataPipe data_pipe(options);
+ request->body[i] = data_pipe.consumer_handle.Pass();
+ WriteDataRaw(data_pipe.producer_handle.get(), body_[i].data(), &num_bytes,
+ MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
+ DCHECK_EQ(num_bytes, body_[i].size());
+ }
+ }
+
+ return request.Pass();
+}
+
+} // namespace web_view
« 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