Chromium Code Reviews| Index: content/browser/appcache/appcache_navigation_handle_core.cc |
| diff --git a/content/browser/appcache/appcache_navigation_handle_core.cc b/content/browser/appcache/appcache_navigation_handle_core.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..759df91277744ab4175ee138d8b187cc20dfbcf9 |
| --- /dev/null |
| +++ b/content/browser/appcache/appcache_navigation_handle_core.cc |
| @@ -0,0 +1,104 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/appcache/appcache_navigation_handle_core.h" |
| + |
| +#include <utility> |
| + |
| +#include "base/bind.h" |
| +#include "content/browser/appcache/appcache_dispatcher_host.h" |
| +#include "content/browser/appcache/appcache_host.h" |
| +#include "content/browser/appcache/appcache_navigation_handle.h" |
| +#include "content/browser/appcache/appcache_service_impl.h" |
| +#include "content/browser/appcache/chrome_appcache_service.h" |
| + |
| +namespace content { |
| + |
| +AppCacheNavigationHandleCore::AppCacheNavigationHandleCore( |
| + base::WeakPtr<AppCacheNavigationHandle> ui_handle, |
| + ChromeAppCacheService* appcache_service, |
| + int appcache_host_id) |
| + : appcache_service_(appcache_service), |
| + appcache_host_id_(appcache_host_id), |
| + ui_handle_(ui_handle) { |
| + // The AppCacheNavigationHandleCore is created on the UI thread but |
| + // should only be accessed from the IO thread afterwards. |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| +} |
| + |
| +AppCacheNavigationHandleCore::~AppCacheNavigationHandleCore() { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + if (precreated_host_.get()) |
|
michaeln
2016/12/03 00:58:58
is the test and reset call explicitly needed, std:
ananta
2016/12/03 14:55:04
Done.
|
| + precreated_host_.reset(nullptr); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::Initialize() { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + DCHECK(precreated_host_.get() == nullptr); |
| + precreated_host_.reset( |
| + new AppCacheHost(appcache_host_id_, this, GetAppCacheService())); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::CommitNavigation(int process_id) { |
| + scoped_refptr<AppCacheDispatcherHost> dispatcher_host = |
| + AppCacheDispatcherHost::GetHostForProcess(process_id); |
|
michaeln
2016/12/03 00:58:58
ah... the map is accessed on the IO thread
Maybe
ananta
2016/12/03 14:55:04
The renderer process has not registered with the h
|
| + // We release ownership of the precreated_host_ here. From this point on |
| + // the AppCacheBackendImpl class owns the host. |
| + if (dispatcher_host.get()) |
| + dispatcher_host->RegisterPrecreatedHost(std::move(precreated_host_)); |
| +} |
| + |
| +AppCacheServiceImpl* AppCacheNavigationHandleCore::GetAppCacheService() { |
| + return static_cast<AppCacheServiceImpl*>(appcache_service_.get()); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnCacheSelected(int host_id, |
| + const AppCacheInfo& info) { |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnStatusChanged( |
| + const std::vector<int>& host_ids, |
| + AppCacheStatus status) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnEventRaised( |
| + const std::vector<int>& host_ids, |
| + AppCacheEventID event_id) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnProgressEventRaised( |
| + const std::vector<int>& host_ids, |
| + const GURL& url, |
| + int num_total, |
| + int num_complete) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnErrorEventRaised( |
| + const std::vector<int>& host_ids, |
| + const AppCacheErrorDetails& details) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnLogMessage(int host_id, |
| + AppCacheLogLevel log_level, |
| + const std::string& message) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +void AppCacheNavigationHandleCore::OnContentBlocked(int host_id, |
| + const GURL& manifest_url) { |
| + // Should never be called. |
| + DCHECK(false); |
| +} |
| + |
| +} // namespace content |