| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/signin/merge_session_resource_throttle.h
" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_resource_throttle.h
" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" | 7 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
| 8 #include "chrome/browser/chromeos/login/signin/merge_session_xhr_request_waiter.
h" | 8 #include "chrome/browser/chromeos/login/signin/merge_session_xhr_request_waiter.
h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 11 #include "content/public/browser/resource_controller.h" | 11 #include "content/public/browser/resource_controller.h" |
| 12 #include "content/public/browser/resource_request_info.h" | 12 #include "content/public/browser/resource_request_info.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 | 15 |
| 16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 using content::RenderViewHost; | 17 using content::RenderViewHost; |
| 18 using content::WebContents; | 18 using content::WebContents; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 void DelayXHRLoadOnUIThread( | 22 void DelayXHRLoadOnUIThread( |
| 23 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 23 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 24 const GURL& url, | 24 const GURL& url, |
| 25 const merge_session_throttling_utils::CompletionCallback& callback) { | 25 const merge_session_throttling_utils::CompletionCallback& callback) { |
| 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 27 WebContents* web_contents = web_contents_getter.Run(); | 27 WebContents* web_contents = web_contents_getter.Run(); |
| 28 if (web_contents && | 28 if (web_contents && |
| 29 merge_session_throttling_utils::ShouldDelayRequest(web_contents)) { | 29 merge_session_throttling_utils::ShouldDelayRequestForWebContents( |
| 30 web_contents)) { |
| 30 DVLOG(1) << "Creating XHR waiter for " << url.spec(); | 31 DVLOG(1) << "Creating XHR waiter for " << url.spec(); |
| 31 Profile* profile = | 32 Profile* profile = |
| 32 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 33 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 33 | 34 |
| 34 // The MergeSessionXHRRequestWaiter will delete itself once it is done | 35 // The MergeSessionXHRRequestWaiter will delete itself once it is done |
| 35 // blocking the request. | 36 // blocking the request. |
| 36 (new chromeos::MergeSessionXHRRequestWaiter(profile, callback)) | 37 (new chromeos::MergeSessionXHRRequestWaiter(profile, callback)) |
| 37 ->StartWaiting(); | 38 ->StartWaiting(); |
| 38 } else { | 39 } else { |
| 39 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback); | 40 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 72 } |
| 72 | 73 |
| 73 const char* MergeSessionResourceThrottle::GetNameForLogging() const { | 74 const char* MergeSessionResourceThrottle::GetNameForLogging() const { |
| 74 return "MergeSessionResourceThrottle"; | 75 return "MergeSessionResourceThrottle"; |
| 75 } | 76 } |
| 76 | 77 |
| 77 void MergeSessionResourceThrottle::OnBlockingPageComplete() { | 78 void MergeSessionResourceThrottle::OnBlockingPageComplete() { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 79 controller()->Resume(); | 80 controller()->Resume(); |
| 80 } | 81 } |
| OLD | NEW |