Commit ec103cf0 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

AppCache: Minor code cleanups.

Change-Id: Iaee118571685b3018bcf377391953543e73733f0
Reviewed-on: https://chromium-review.googlesource.com/1141452
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575961}
parent b90df404
......@@ -8,11 +8,10 @@
#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.
// Used to generate the host id for a navigation initiated by the browser.
// Starts at -1 and keeps going down.
static int g_next_appcache_host_id = -1;
}
......@@ -20,13 +19,10 @@ namespace content {
AppCacheNavigationHandle::AppCacheNavigationHandle(
ChromeAppCacheService* appcache_service)
: appcache_host_id_(kAppCacheNoHostId),
core_(nullptr),
weak_factory_(this) {
: appcache_host_id_(g_next_appcache_host_id--),
core_(std::make_unique<AppCacheNavigationHandleCore>(appcache_service,
appcache_host_id_)) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
appcache_host_id_ = g_next_appcache_host_id--;
core_ = std::make_unique<AppCacheNavigationHandleCore>(appcache_service,
appcache_host_id_);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&AppCacheNavigationHandleCore::Initialize,
......
......@@ -7,8 +7,6 @@
#include <memory>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
namespace content {
......@@ -42,7 +40,7 @@ class ChromeAppCacheService;
// update the RequestNavigationParams based on the id from the
// AppCacheNavigationHandle.
//
// 6. The commit leads to AppCache registrations happening from the renderer.
// 6) The commit leads to AppCache registrations happening from the renderer.
// This is via the IPC message AppCacheHostMsg_RegisterHost. The
// AppCacheDispatcherHost class which handles these IPCs will be informed
// about these hosts when the navigation commits. It will ignore the
......@@ -52,24 +50,19 @@ class ChromeAppCacheService;
// 7) When the navigation finishes, the AppCacheNavigationHandle is
// destroyed. The destructor of the AppCacheNavigationHandle posts a
// task to destroy the AppacheNavigationHandleCore on the IO thread.
// task to destroy the AppCacheNavigationHandleCore on the IO thread.
class AppCacheNavigationHandle {
public:
AppCacheNavigationHandle(ChromeAppCacheService* appcache_service);
explicit AppCacheNavigationHandle(ChromeAppCacheService* appcache_service);
~AppCacheNavigationHandle();
int appcache_host_id() const { return appcache_host_id_; }
AppCacheNavigationHandleCore* core() const { return core_.get(); }
// Called when a navigation is committed. The |process_id| parameter is
// is the process id of the renderer.
void CommitNavigation(int process_id);
private:
int appcache_host_id_;
const int appcache_host_id_;
std::unique_ptr<AppCacheNavigationHandleCore> core_;
base::WeakPtrFactory<AppCacheNavigationHandle> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AppCacheNavigationHandle);
};
......
......@@ -5,21 +5,19 @@
#include "content/renderer/appcache/web_application_cache_host_impl.h"
#include <stddef.h>
#include <vector>
#include "base/compiler_specific.h"
#include "base/containers/id_map.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/platform/web_url_response.h"
using blink::WebApplicationCacheHost;
using blink::WebApplicationCacheHostClient;
using blink::WebString;
using blink::WebURLRequest;
using blink::WebURL;
using blink::WebURLResponse;
using blink::WebVector;
......@@ -70,7 +68,6 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
DCHECK(client && backend);
// PlzNavigate: The browser passes the ID to be used.
if (appcache_host_id != kAppCacheNoHostId) {
DCHECK(IsBrowserSideNavigationEnabled());
all_hosts()->AddWithID(this, appcache_host_id);
host_id_ = appcache_host_id;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment