OLD | NEW |
(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 "base/callback.h" |
| 6 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 7 #include "content/browser/loader/global_routing_id.h" |
| 8 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/loader_io_thread_notifier.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 namespace { |
| 15 |
| 16 void NotifyForFrameOnIO( |
| 17 base::Callback<void(ResourceDispatcherHostImpl*, |
| 18 const GlobalFrameRoutingId&)> frame_callback, |
| 19 const GlobalFrameRoutingId& routing_id) { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 21 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 22 if (rdh) |
| 23 frame_callback.Run(rdh, routing_id); |
| 24 } |
| 25 |
| 26 } // namespace |
| 27 |
| 28 // static |
| 29 void LoaderIOThreadNotifier::BlockRequestsForFrame( |
| 30 RenderFrameHost* frame_host) { |
| 31 BrowserThread::PostTask( |
| 32 BrowserThread::IO, FROM_HERE, |
| 33 base::Bind(&NotifyForFrameOnIO, |
| 34 base::Bind(&ResourceDispatcherHostImpl::BlockRequestsForFrame), |
| 35 static_cast<RenderFrameHostImpl*>(frame_host) |
| 36 ->GetGlobalFrameRoutingId())); |
| 37 } |
| 38 |
| 39 void LoaderIOThreadNotifier::ResumeBlockedRequestsForFrame( |
| 40 RenderFrameHost* frame_host) { |
| 41 BrowserThread::PostTask( |
| 42 BrowserThread::IO, FROM_HERE, |
| 43 base::Bind( |
| 44 &NotifyForFrameOnIO, |
| 45 base::Bind( |
| 46 &ResourceDispatcherHostImpl::ResumeBlockedRequestsForFrame), |
| 47 static_cast<RenderFrameHostImpl*>(frame_host) |
| 48 ->GetGlobalFrameRoutingId())); |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |