OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_throttle.h" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_throttle.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 ProfileSet* ProfileSet::Get() { | 67 ProfileSet* ProfileSet::Get() { |
68 return g_blocked_profiles.Pointer(); | 68 return g_blocked_profiles.Pointer(); |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 base::AtomicRefCount MergeSessionThrottle::all_profiles_restored_(0); | 73 base::AtomicRefCount MergeSessionThrottle::all_profiles_restored_(0); |
74 | 74 |
75 MergeSessionThrottle::MergeSessionThrottle(net::URLRequest* request, | 75 MergeSessionThrottle::MergeSessionThrottle(net::URLRequest* request, |
76 ResourceType::Type resource_type) | 76 ResourceType resource_type) |
77 : request_(request), | 77 : request_(request), |
78 resource_type_(resource_type) { | 78 resource_type_(resource_type) { |
79 } | 79 } |
80 | 80 |
81 MergeSessionThrottle::~MergeSessionThrottle() { | 81 MergeSessionThrottle::~MergeSessionThrottle() { |
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
83 } | 83 } |
84 | 84 |
85 void MergeSessionThrottle::WillStartRequest(bool* defer) { | 85 void MergeSessionThrottle::WillStartRequest(bool* defer) { |
86 if (!ShouldDelayUrl(request_->url())) | 86 if (!ShouldDelayUrl(request_->url())) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return false; | 236 return false; |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 NOTREACHED(); | 240 NOTREACHED(); |
241 return false; | 241 return false; |
242 } | 242 } |
243 | 243 |
244 // static. | 244 // static. |
245 void MergeSessionThrottle::DeleayResourceLoadingOnUIThread( | 245 void MergeSessionThrottle::DeleayResourceLoadingOnUIThread( |
246 ResourceType::Type resource_type, | 246 ResourceType resource_type, |
247 int render_process_id, | 247 int render_process_id, |
248 int render_view_id, | 248 int render_view_id, |
249 const GURL& url, | 249 const GURL& url, |
250 const CompletionCallback& callback) { | 250 const CompletionCallback& callback) { |
251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
252 | 252 |
253 if (ShouldDelayRequest(render_process_id, render_view_id)) { | 253 if (ShouldDelayRequest(render_process_id, render_view_id)) { |
254 // There is a chance that the tab closed after we decided to show | 254 // There is a chance that the tab closed after we decided to show |
255 // the offline page on the IO thread and before we actually show the | 255 // the offline page on the IO thread and before we actually show the |
256 // offline page here on the UI thread. | 256 // offline page here on the UI thread. |
257 RenderViewHost* render_view_host = | 257 RenderViewHost* render_view_host = |
258 RenderViewHost::FromID(render_process_id, render_view_id); | 258 RenderViewHost::FromID(render_process_id, render_view_id); |
259 WebContents* web_contents = render_view_host ? | 259 WebContents* web_contents = render_view_host ? |
260 WebContents::FromRenderViewHost(render_view_host) : NULL; | 260 WebContents::FromRenderViewHost(render_view_host) : NULL; |
261 if (resource_type == ResourceType::MAIN_FRAME) { | 261 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { |
262 DVLOG(1) << "Creating page waiter for " << url.spec(); | 262 DVLOG(1) << "Creating page waiter for " << url.spec(); |
263 (new chromeos::MergeSessionLoadPage(web_contents, url, callback))->Show(); | 263 (new chromeos::MergeSessionLoadPage(web_contents, url, callback))->Show(); |
264 } else { | 264 } else { |
265 DVLOG(1) << "Creating XHR waiter for " << url.spec(); | 265 DVLOG(1) << "Creating XHR waiter for " << url.spec(); |
266 DCHECK(resource_type == ResourceType::XHR); | 266 DCHECK(resource_type == content::RESOURCE_TYPE_XHR); |
267 Profile* profile = Profile::FromBrowserContext( | 267 Profile* profile = Profile::FromBrowserContext( |
268 web_contents->GetBrowserContext()); | 268 web_contents->GetBrowserContext()); |
269 (new chromeos::MergeSessionXHRRequestWaiter(profile, | 269 (new chromeos::MergeSessionXHRRequestWaiter(profile, |
270 callback))->StartWaiting(); | 270 callback))->StartWaiting(); |
271 } | 271 } |
272 } else { | 272 } else { |
273 BrowserThread::PostTask( | 273 BrowserThread::PostTask( |
274 BrowserThread::IO, FROM_HERE, callback); | 274 BrowserThread::IO, FROM_HERE, callback); |
275 } | 275 } |
276 } | 276 } |
OLD | NEW |