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 @@
namespace content {
namespace {
AppCacheInfoCollection::AppCacheInfoCollection() = default;
void DeferredCallback(OnceCompletionCallback callback, int rv) {
std::move(callback).Run(rv);
}
} // namespace
AppCacheInfoCollection::AppCacheInfoCollection() {}
AppCacheInfoCollection::~AppCacheInfoCollection() {}
AppCacheInfoCollection::~AppCacheInfoCollection() = default;
// AsyncHelper -------
class AppCacheServiceImpl::AsyncHelper
: public AppCacheStorage::Delegate {
class AppCacheServiceImpl::AsyncHelper : public AppCacheStorage::Delegate {
public:
AsyncHelper(AppCacheServiceImpl* service, OnceCompletionCallback callback)
: service_(service), callback_(std::move(callback)) {
......@@ -64,13 +55,12 @@ class AppCacheServiceImpl::AsyncHelper
protected:
void CallCallback(int rv) {
if (!callback_.is_null()) {
if (callback_) {
// Defer to guarantee async completion.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(&DeferredCallback, std::move(callback_), rv));
FROM_HERE, base::BindOnce(std::move(callback_), rv));
}
callback_.Reset();
DCHECK(!callback_);
}
AppCacheServiceImpl* service_;
......@@ -442,9 +432,9 @@ void AppCacheServiceImpl::ScheduleReinitialize() {
// leave the appcache disabled for an indefinite period of time. Some
// users never shutdown the browser.
const base::TimeDelta kZeroDelta;
const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1));
const base::TimeDelta k30Seconds(base::TimeDelta::FromSeconds(30));
constexpr base::TimeDelta kZeroDelta;
constexpr base::TimeDelta kOneHour = base::TimeDelta::FromHours(1);
constexpr base::TimeDelta kThirtySeconds = base::TimeDelta::FromSeconds(30);
// 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.
......@@ -456,7 +446,7 @@ void AppCacheServiceImpl::ScheduleReinitialize() {
this, &AppCacheServiceImpl::Reinitialize);
// 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);
}
......@@ -514,8 +504,7 @@ void AppCacheServiceImpl::set_special_storage_policy(
void AppCacheServiceImpl::RegisterBackend(
AppCacheBackendImpl* backend_impl) {
DCHECK(backends_.find(backend_impl->process_id()) == backends_.end());
backends_.insert(
BackendMap::value_type(backend_impl->process_id(), backend_impl));
backends_.insert({backend_impl->process_id(), backend_impl});
}
void AppCacheServiceImpl::UnregisterBackend(
......
......@@ -65,8 +65,7 @@ class CONTENT_EXPORT AppCacheStorageReference
// Class that manages the application cache service. Sends notifications
// to many frontends. One instance per user-profile. Each instance has
// exclusive access to its cache_directory on disk.
class CONTENT_EXPORT AppCacheServiceImpl
: public AppCacheService {
class CONTENT_EXPORT AppCacheServiceImpl : public AppCacheService {
public:
class CONTENT_EXPORT Observer {
......@@ -154,8 +153,8 @@ class CONTENT_EXPORT AppCacheServiceImpl
void RegisterBackend(AppCacheBackendImpl* backend_impl);
virtual void UnregisterBackend(AppCacheBackendImpl* backend_impl);
AppCacheBackendImpl* GetBackend(int id) const {
BackendMap::const_iterator it = backends_.find(id);
return (it != backends_.end()) ? it->second : NULL;
auto it = backends_.find(id);
return (it != backends_.end()) ? it->second : nullptr;
}
AppCacheStorage* storage() const { return storage_.get(); }
......@@ -192,10 +191,6 @@ class CONTENT_EXPORT AppCacheServiceImpl
class GetInfoHelper;
class CheckResponseHelper;
using PendingAsyncHelpers =
std::map<AsyncHelper*, std::unique_ptr<AsyncHelper>>;
using BackendMap = std::map<int, AppCacheBackendImpl*>;
void Reinitialize();
base::FilePath cache_directory_;
......@@ -205,8 +200,9 @@ class CONTENT_EXPORT AppCacheServiceImpl
std::unique_ptr<AppCacheStorage> storage_;
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_;
PendingAsyncHelpers pending_helpers_;
BackendMap backends_; // One 'backend' per child process.
std::map<AsyncHelper*, std::unique_ptr<AsyncHelper>> pending_helpers_;
// One 'backend' per child process.
std::map<int, AppCacheBackendImpl*> backends_;
// Context for use during cache updates.
net::URLRequestContext* request_context_;
// 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