Index: content/public/browser/loader_io_thread_notifier.cc |
diff --git a/content/public/browser/loader_io_thread_notifier.cc b/content/public/browser/loader_io_thread_notifier.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4a18de8bff4deabe0f66536edcd0f11c837f3ce5 |
--- /dev/null |
+++ b/content/public/browser/loader_io_thread_notifier.cc |
@@ -0,0 +1,51 @@ |
+// 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 "base/callback.h" |
+#include "content/browser/frame_host/render_frame_host_impl.h" |
+#include "content/browser/loader/global_routing_id.h" |
+#include "content/browser/loader/resource_dispatcher_host_impl.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/loader_io_thread_notifier.h" |
+ |
+namespace content { |
+ |
+namespace { |
+ |
+void NotifyForFrameOnIO( |
+ base::Callback<void(ResourceDispatcherHostImpl*, |
+ const GlobalFrameRoutingId&)> frame_callback, |
+ const GlobalFrameRoutingId& routing_id) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
+ if (rdh) |
+ frame_callback.Run(rdh, routing_id); |
+} |
+ |
+} // namespace |
+ |
+// static |
+void LoaderIOThreadNotifier::BlockRequestsForFrame( |
+ RenderFrameHost* frame_host) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&NotifyForFrameOnIO, |
+ base::Bind(&ResourceDispatcherHostImpl::BlockRequestsForFrame), |
+ static_cast<RenderFrameHostImpl*>(frame_host) |
+ ->GetGlobalFrameRoutingId())); |
+} |
+ |
+void LoaderIOThreadNotifier::ResumeBlockedRequestsForFrame( |
+ RenderFrameHost* frame_host) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind( |
+ &NotifyForFrameOnIO, |
+ base::Bind( |
+ &ResourceDispatcherHostImpl::ResumeBlockedRequestsForFrame), |
+ static_cast<RenderFrameHostImpl*>(frame_host) |
+ ->GetGlobalFrameRoutingId())); |
+} |
+ |
+} // namespace content |