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

Unified Diff: content/browser/loader/url_loader_factory_impl.cc

Issue 2390983003: Implement Mojo SyncLoad (Closed)
Patch Set: +comment Created 4 years, 2 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
Index: content/browser/loader/url_loader_factory_impl.cc
diff --git a/content/browser/loader/url_loader_factory_impl.cc b/content/browser/loader/url_loader_factory_impl.cc
index 7b11666452e2683045457b408c5fb466e06c4243..4d61deefe1999cd65b5d918d9c1a7af6b44a8046 100644
--- a/content/browser/loader/url_loader_factory_impl.cc
+++ b/content/browser/loader/url_loader_factory_impl.cc
@@ -13,6 +13,23 @@
namespace content {
+namespace {
+
+void DispatchSyncLoadResult(
+ const URLLoaderFactoryImpl::SyncLoadCallback& callback,
+ const SyncLoadResult* result) {
+ if (!result) {
+ SyncLoadResult failure;
+ failure.error_code = net::ERR_FAILED;
+ callback.Run(failure);
+ return;
+ }
+
+ callback.Run(*result);
+}
+
+} // namespace
+
URLLoaderFactoryImpl::URLLoaderFactoryImpl(
scoped_refptr<ResourceMessageFilter> resource_message_filter)
: resource_message_filter_(std::move(resource_message_filter)) {
@@ -38,6 +55,20 @@ void URLLoaderFactoryImpl::CreateLoaderAndStart(
resource_message_filter_.get());
}
+void URLLoaderFactoryImpl::SyncLoad(int32_t request_id,
+ const ResourceRequest& url_request,
+ const SyncLoadCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // TODO(yhirano): Provide the right routing ID.
yhirano 2016/10/12 10:55:30 Please provide the routing ID.
tzik 2016/10/12 12:06:00 Done.
+ const int routing_id = 0;
+ SyncLoadResult result;
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
+ rdh->OnSyncLoadWithMojo(routing_id, request_id, url_request,
+ resource_message_filter_.get(),
+ base::Bind(&DispatchSyncLoadResult, callback));
+}
+
void URLLoaderFactoryImpl::Create(
scoped_refptr<ResourceMessageFilter> filter,
mojo::InterfaceRequest<mojom::URLLoaderFactory> request) {

Powered by Google App Engine
This is Rietveld 408576698