Commit 6615e630 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Remove unnecessary types from AppCacheServiceImpl.

Change-Id: I03d1e0ba27eae87f73862027b52d3d46aff09179
Reviewed-on: https://chromium-review.googlesource.com/1185785
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585494}
parent 2e954351
...@@ -30,22 +30,13 @@ ...@@ -30,22 +30,13 @@
namespace content { namespace content {
namespace { AppCacheInfoCollection::AppCacheInfoCollection() = default;
void DeferredCallback(OnceCompletionCallback callback, int rv) { AppCacheInfoCollection::~AppCacheInfoCollection() = default;
std::move(callback).Run(rv);
}
} // namespace
AppCacheInfoCollection::AppCacheInfoCollection() {}
AppCacheInfoCollection::~AppCacheInfoCollection() {}
// AsyncHelper ------- // AsyncHelper -------
class AppCacheServiceImpl::AsyncHelper class AppCacheServiceImpl::AsyncHelper : public AppCacheStorage::Delegate {
: public AppCacheStorage::Delegate {
public: public:
AsyncHelper(AppCacheServiceImpl* service, OnceCompletionCallback callback) AsyncHelper(AppCacheServiceImpl* service, OnceCompletionCallback callback)
: service_(service), callback_(std::move(callback)) { : service_(service), callback_(std::move(callback)) {
...@@ -64,13 +55,12 @@ class AppCacheServiceImpl::AsyncHelper ...@@ -64,13 +55,12 @@ class AppCacheServiceImpl::AsyncHelper
protected: protected:
void CallCallback(int rv) { void CallCallback(int rv) {
if (!callback_.is_null()) { if (callback_) {
// Defer to guarantee async completion. // Defer to guarantee async completion.
base::SequencedTaskRunnerHandle::Get()->PostTask( base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(std::move(callback_), rv));
base::BindOnce(&DeferredCallback, std::move(callback_), rv));
} }
callback_.Reset(); DCHECK(!callback_);
} }
AppCacheServiceImpl* service_; AppCacheServiceImpl* service_;
...@@ -442,9 +432,9 @@ void AppCacheServiceImpl::ScheduleReinitialize() { ...@@ -442,9 +432,9 @@ void AppCacheServiceImpl::ScheduleReinitialize() {
// leave the appcache disabled for an indefinite period of time. Some // leave the appcache disabled for an indefinite period of time. Some
// users never shutdown the browser. // users never shutdown the browser.
const base::TimeDelta kZeroDelta; constexpr base::TimeDelta kZeroDelta;
const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1)); constexpr base::TimeDelta kOneHour = base::TimeDelta::FromHours(1);
const base::TimeDelta k30Seconds(base::TimeDelta::FromSeconds(30)); constexpr base::TimeDelta kThirtySeconds = base::TimeDelta::FromSeconds(30);
// If the system managed to stay up for long enough, reset the // If the system managed to stay up for long enough, reset the
// delay so a new failure won't incur a long wait to get going again. // delay so a new failure won't incur a long wait to get going again.
...@@ -456,7 +446,7 @@ void AppCacheServiceImpl::ScheduleReinitialize() { ...@@ -456,7 +446,7 @@ void AppCacheServiceImpl::ScheduleReinitialize() {
this, &AppCacheServiceImpl::Reinitialize); this, &AppCacheServiceImpl::Reinitialize);
// Adjust the delay for next time. // Adjust the delay for next time.
base::TimeDelta increment = std::max(k30Seconds, next_reinit_delay_); base::TimeDelta increment = std::max(kThirtySeconds, next_reinit_delay_);
next_reinit_delay_ = std::min(next_reinit_delay_ + increment, kOneHour); next_reinit_delay_ = std::min(next_reinit_delay_ + increment, kOneHour);
} }
...@@ -514,8 +504,7 @@ void AppCacheServiceImpl::set_special_storage_policy( ...@@ -514,8 +504,7 @@ void AppCacheServiceImpl::set_special_storage_policy(
void AppCacheServiceImpl::RegisterBackend( void AppCacheServiceImpl::RegisterBackend(
AppCacheBackendImpl* backend_impl) { AppCacheBackendImpl* backend_impl) {
DCHECK(backends_.find(backend_impl->process_id()) == backends_.end()); DCHECK(backends_.find(backend_impl->process_id()) == backends_.end());
backends_.insert( backends_.insert({backend_impl->process_id(), backend_impl});
BackendMap::value_type(backend_impl->process_id(), backend_impl));
} }
void AppCacheServiceImpl::UnregisterBackend( void AppCacheServiceImpl::UnregisterBackend(
......
...@@ -65,8 +65,7 @@ class CONTENT_EXPORT AppCacheStorageReference ...@@ -65,8 +65,7 @@ class CONTENT_EXPORT AppCacheStorageReference
// Class that manages the application cache service. Sends notifications // Class that manages the application cache service. Sends notifications
// to many frontends. One instance per user-profile. Each instance has // to many frontends. One instance per user-profile. Each instance has
// exclusive access to its cache_directory on disk. // exclusive access to its cache_directory on disk.
class CONTENT_EXPORT AppCacheServiceImpl class CONTENT_EXPORT AppCacheServiceImpl : public AppCacheService {
: public AppCacheService {
public: public:
class CONTENT_EXPORT Observer { class CONTENT_EXPORT Observer {
...@@ -154,8 +153,8 @@ class CONTENT_EXPORT AppCacheServiceImpl ...@@ -154,8 +153,8 @@ class CONTENT_EXPORT AppCacheServiceImpl
void RegisterBackend(AppCacheBackendImpl* backend_impl); void RegisterBackend(AppCacheBackendImpl* backend_impl);
virtual void UnregisterBackend(AppCacheBackendImpl* backend_impl); virtual void UnregisterBackend(AppCacheBackendImpl* backend_impl);
AppCacheBackendImpl* GetBackend(int id) const { AppCacheBackendImpl* GetBackend(int id) const {
BackendMap::const_iterator it = backends_.find(id); auto it = backends_.find(id);
return (it != backends_.end()) ? it->second : NULL; return (it != backends_.end()) ? it->second : nullptr;
} }
AppCacheStorage* storage() const { return storage_.get(); } AppCacheStorage* storage() const { return storage_.get(); }
...@@ -192,10 +191,6 @@ class CONTENT_EXPORT AppCacheServiceImpl ...@@ -192,10 +191,6 @@ class CONTENT_EXPORT AppCacheServiceImpl
class GetInfoHelper; class GetInfoHelper;
class CheckResponseHelper; class CheckResponseHelper;
using PendingAsyncHelpers =
std::map<AsyncHelper*, std::unique_ptr<AsyncHelper>>;
using BackendMap = std::map<int, AppCacheBackendImpl*>;
void Reinitialize(); void Reinitialize();
base::FilePath cache_directory_; base::FilePath cache_directory_;
...@@ -205,8 +200,9 @@ class CONTENT_EXPORT AppCacheServiceImpl ...@@ -205,8 +200,9 @@ class CONTENT_EXPORT AppCacheServiceImpl
std::unique_ptr<AppCacheStorage> storage_; std::unique_ptr<AppCacheStorage> storage_;
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_;
PendingAsyncHelpers pending_helpers_; std::map<AsyncHelper*, std::unique_ptr<AsyncHelper>> pending_helpers_;
BackendMap backends_; // One 'backend' per child process. // One 'backend' per child process.
std::map<int, AppCacheBackendImpl*> backends_;
// Context for use during cache updates. // Context for use during cache updates.
net::URLRequestContext* request_context_; net::URLRequestContext* request_context_;
// If true, nothing (not even session-only data) should be deleted on exit. // If true, nothing (not even session-only data) should be deleted on exit.
......
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