OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/appcache/appcache_navigation_handle.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "content/browser/appcache/appcache_navigation_handle_core.h" |
| 9 #include "content/browser/appcache/chrome_appcache_service.h" |
| 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/common/appcache_info.h" |
| 12 |
| 13 namespace { |
| 14 // PlzNavigate: Used to generate the host id for a navigation initiated by the |
| 15 // browser. Starts at -2 and keeps going down. |
| 16 static int g_next_appcache_host_id = -1; |
| 17 } |
| 18 |
| 19 namespace content { |
| 20 |
| 21 AppCacheNavigationHandle::AppCacheNavigationHandle( |
| 22 ChromeAppCacheService* appcache_service) |
| 23 : appcache_host_id_(kAppCacheNoHostId), |
| 24 core_(nullptr), |
| 25 weak_factory_(this) { |
| 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 27 appcache_host_id_ = g_next_appcache_host_id--; |
| 28 core_ = new AppCacheNavigationHandleCore( |
| 29 weak_factory_.GetWeakPtr(), |
| 30 appcache_service, |
| 31 appcache_host_id_); |
| 32 BrowserThread::PostTask( |
| 33 BrowserThread::IO, |
| 34 FROM_HERE, |
| 35 base::Bind(&AppCacheNavigationHandleCore::Initialize, |
| 36 base::Unretained(core_))); |
| 37 } |
| 38 |
| 39 AppCacheNavigationHandle::~AppCacheNavigationHandle() { |
| 40 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 41 // Delete the AppCacheNavigationHandleCore on the IO thread. |
| 42 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, core_); |
| 43 } |
| 44 |
| 45 void AppCacheNavigationHandle::CommitNavigation(int process_id) { |
| 46 BrowserThread::PostTask( |
| 47 BrowserThread::IO, |
| 48 FROM_HERE, |
| 49 base::Bind(&AppCacheNavigationHandleCore::CommitNavigation, |
| 50 base::Unretained(core_), |
| 51 process_id)); |
| 52 } |
| 53 |
| 54 } // namespace content |
OLD | NEW |