Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Unified Diff: content/browser/appcache/appcache_navigation_handle.cc

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Rebase to tip correctly Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/appcache/appcache_navigation_handle.cc
diff --git a/content/browser/appcache/appcache_navigation_handle.cc b/content/browser/appcache/appcache_navigation_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..409767488d528364dd369259b553c1470aa435a6
--- /dev/null
+++ b/content/browser/appcache/appcache_navigation_handle.cc
@@ -0,0 +1,48 @@
+// 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.h"
+
+#include "base/bind.h"
+#include "content/browser/appcache/appcache_navigation_handle_core.h"
+#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/common/appcache_info.h"
+
+namespace {
+// PlzNavigate: Used to generate the host id for a navigation initiated by the
+// browser. Starts at -2 and keeps going down.
+static int g_next_appcache_host_id = -1;
+}
+
+namespace content {
+
+AppCacheNavigationHandle::AppCacheNavigationHandle(
+ ChromeAppCacheService* appcache_service)
+ : appcache_host_id_(kAppCacheNoHostId),
+ core_(nullptr),
+ weak_factory_(this) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ appcache_host_id_ = g_next_appcache_host_id--;
+ core_ = new AppCacheNavigationHandleCore(weak_factory_.GetWeakPtr(),
+ appcache_service, appcache_host_id_);
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&AppCacheNavigationHandleCore::Initialize,
+ base::Unretained(core_)));
+}
+
+AppCacheNavigationHandle::~AppCacheNavigationHandle() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ // Delete the AppCacheNavigationHandleCore on the IO thread.
+ BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, core_);
+}
+
+void AppCacheNavigationHandle::CommitNavigation(int process_id) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&AppCacheNavigationHandleCore::CommitNavigation,
+ base::Unretained(core_), process_id));
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698