Commit 6992af00 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[AppCache] Move frontend instance from dispatcher host to backend impl.

This is the first step towards merging DispatcherHost into BackendImpl.

Bug: none
Change-Id: If0a387b71968823cd50dfff628f758ef6fc01e63
Reviewed-on: https://chromium-review.googlesource.com/c/1450752
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628573}
parent e01b7e54
...@@ -12,23 +12,19 @@ ...@@ -12,23 +12,19 @@
namespace content { namespace content {
AppCacheBackendImpl::AppCacheBackendImpl() AppCacheBackendImpl::AppCacheBackendImpl(AppCacheServiceImpl* service,
: service_(nullptr), frontend_(nullptr), process_id_(0) {} int process_id)
: service_(service),
frontend_proxy_(process_id),
frontend_(&frontend_proxy_),
process_id_(process_id) {
DCHECK(service);
service_->RegisterBackend(this);
}
AppCacheBackendImpl::~AppCacheBackendImpl() { AppCacheBackendImpl::~AppCacheBackendImpl() {
hosts_.clear(); hosts_.clear();
if (service_) service_->UnregisterBackend(this);
service_->UnregisterBackend(this);
}
void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service,
blink::mojom::AppCacheFrontend* frontend,
int process_id) {
DCHECK(!service_ && !frontend_ && frontend && service);
service_ = service;
frontend_ = frontend;
process_id_ = process_id;
service_->RegisterBackend(this);
} }
bool AppCacheBackendImpl::RegisterHost(int id) { bool AppCacheBackendImpl::RegisterHost(int id) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdint.h> #include <stdint.h>
#include "content/browser/appcache/appcache_frontend_proxy.h"
#include "content/browser/appcache/appcache_host.h" #include "content/browser/appcache/appcache_host.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h" #include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
...@@ -17,13 +18,9 @@ class AppCacheServiceImpl; ...@@ -17,13 +18,9 @@ class AppCacheServiceImpl;
class CONTENT_EXPORT AppCacheBackendImpl { class CONTENT_EXPORT AppCacheBackendImpl {
public: public:
AppCacheBackendImpl(); AppCacheBackendImpl(AppCacheServiceImpl* service, int process_id);
~AppCacheBackendImpl(); ~AppCacheBackendImpl();
void Initialize(AppCacheServiceImpl* service,
blink::mojom::AppCacheFrontend* frontend,
int process_id);
int process_id() const { return process_id_; } int process_id() const { return process_id_; }
// Methods to support the AppCacheBackend interface. A false return // Methods to support the AppCacheBackend interface. A false return
...@@ -68,8 +65,13 @@ class CONTENT_EXPORT AppCacheBackendImpl { ...@@ -68,8 +65,13 @@ class CONTENT_EXPORT AppCacheBackendImpl {
// this function and ignore registrations for this host id from the renderer. // this function and ignore registrations for this host id from the renderer.
void RegisterPrecreatedHost(std::unique_ptr<AppCacheHost> host); void RegisterPrecreatedHost(std::unique_ptr<AppCacheHost> host);
void set_frontend_for_testing(blink::mojom::AppCacheFrontend* frontend) {
frontend_ = frontend;
}
private: private:
AppCacheServiceImpl* service_; AppCacheServiceImpl* service_;
AppCacheFrontendProxy frontend_proxy_;
blink::mojom::AppCacheFrontend* frontend_; blink::mojom::AppCacheFrontend* frontend_;
int process_id_; int process_id_;
HostMap hosts_; HostMap hosts_;
......
...@@ -19,10 +19,7 @@ namespace content { ...@@ -19,10 +19,7 @@ namespace content {
AppCacheDispatcherHost::AppCacheDispatcherHost( AppCacheDispatcherHost::AppCacheDispatcherHost(
ChromeAppCacheService* appcache_service, ChromeAppCacheService* appcache_service,
int process_id) int process_id)
: frontend_proxy_(process_id) { : backend_impl_(appcache_service, process_id) {}
DCHECK(appcache_service);
backend_impl_.Initialize(appcache_service, &frontend_proxy_, process_id);
}
AppCacheDispatcherHost::~AppCacheDispatcherHost() = default; AppCacheDispatcherHost::~AppCacheDispatcherHost() = default;
......
...@@ -55,7 +55,6 @@ class AppCacheDispatcherHost : public blink::mojom::AppCacheBackend { ...@@ -55,7 +55,6 @@ class AppCacheDispatcherHost : public blink::mojom::AppCacheBackend {
void GetResourceList(int32_t host_id, void GetResourceList(int32_t host_id,
GetResourceListCallback callback) override; GetResourceListCallback callback) override;
AppCacheFrontendProxy frontend_proxy_;
AppCacheBackendImpl backend_impl_; AppCacheBackendImpl backend_impl_;
DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost);
......
...@@ -254,9 +254,9 @@ class AppCacheRequestHandlerTest ...@@ -254,9 +254,9 @@ class AppCacheRequestHandlerTest
mock_policy_.reset(new MockAppCachePolicy); mock_policy_.reset(new MockAppCachePolicy);
mock_service_->set_appcache_policy(mock_policy_.get()); mock_service_->set_appcache_policy(mock_policy_.get());
mock_frontend_.reset(new MockFrontend); mock_frontend_.reset(new MockFrontend);
backend_impl_.reset(new AppCacheBackendImpl); backend_impl_ = std::make_unique<AppCacheBackendImpl>(mock_service_.get(),
backend_impl_->Initialize(mock_service_.get(), mock_frontend_.get(), kMockProcessId);
kMockProcessId); backend_impl_->set_frontend_for_testing(mock_frontend_.get());
const int kHostId = 1; const int kHostId = 1;
backend_impl_->RegisterHost(kHostId); backend_impl_->RegisterHost(kHostId);
host_ = backend_impl_->GetHost(kHostId); host_ = backend_impl_->GetHost(kHostId);
......
...@@ -1681,8 +1681,9 @@ class AppCacheStorageImplTest : public testing::Test { ...@@ -1681,8 +1681,9 @@ class AppCacheStorageImplTest : public testing::Test {
void Continue_Reinitialize(ReinitTestCase test_case) { void Continue_Reinitialize(ReinitTestCase test_case) {
const int kMockProcessId = 1; const int kMockProcessId = 1;
backend_.reset(new AppCacheBackendImpl); backend_ =
backend_->Initialize(service_.get(), &frontend_, kMockProcessId); std::make_unique<AppCacheBackendImpl>(service_.get(), kMockProcessId);
backend_->set_frontend_for_testing(&frontend_);
if (test_case == CORRUPT_SQL_ON_INSTALL) { if (test_case == CORRUPT_SQL_ON_INSTALL) {
// Break the db file // Break the db file
......
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