Home | History | Annotate | Download | only in frame_host
      1 // Copyright 2014 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 "content/browser/frame_host/cross_site_transferring_request.h"
      6 
      7 #include "base/logging.h"
      8 #include "content/browser/loader/cross_site_resource_handler.h"
      9 #include "content/browser/loader/resource_dispatcher_host_impl.h"
     10 #include "content/public/browser/browser_thread.h"
     11 
     12 namespace content {
     13 
     14 namespace {
     15 
     16 void CancelRequestOnIOThread(GlobalRequestID global_request_id) {
     17   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
     18 
     19   ResourceDispatcherHostImpl::Get()->CancelTransferringNavigation(
     20       global_request_id);
     21 }
     22 
     23 }  // namespace
     24 
     25 CrossSiteTransferringRequest::CrossSiteTransferringRequest(
     26     GlobalRequestID global_request_id)
     27     : global_request_id_(global_request_id) {
     28   DCHECK(global_request_id_ != GlobalRequestID());
     29 }
     30 
     31 CrossSiteTransferringRequest::~CrossSiteTransferringRequest() {
     32   if (global_request_id_ == GlobalRequestID())
     33     return;
     34   BrowserThread::PostTask(
     35       BrowserThread::IO,
     36       FROM_HERE,
     37       base::Bind(&CancelRequestOnIOThread, global_request_id_));
     38 }
     39 
     40 void CrossSiteTransferringRequest::ReleaseRequest() {
     41   DCHECK_NE(-1, global_request_id_.child_id);
     42   DCHECK_NE(-1, global_request_id_.request_id);
     43   global_request_id_ = GlobalRequestID();
     44 }
     45 
     46 }  // namespace content
     47