| Index: components/offline_pages/background/initialize_store_task.cc
|
| diff --git a/components/offline_pages/background/initialize_store_task.cc b/components/offline_pages/background/initialize_store_task.cc
|
| deleted file mode 100644
|
| index da1a57c55a43e6c7a6e643bd41f2ba541bb0069e..0000000000000000000000000000000000000000
|
| --- a/components/offline_pages/background/initialize_store_task.cc
|
| +++ /dev/null
|
| @@ -1,61 +0,0 @@
|
| -// 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 "components/offline_pages/background/initialize_store_task.h"
|
| -
|
| -#include "base/bind.h"
|
| -
|
| -namespace offline_pages {
|
| -
|
| -const int kRestartAttemptsMaximum = 3;
|
| -
|
| -InitializeStoreTask::InitializeStoreTask(
|
| - RequestQueueStore* store,
|
| - const RequestQueueStore::InitializeCallback& callback)
|
| - : store_(store),
|
| - reset_attempts_left_(kRestartAttemptsMaximum),
|
| - callback_(callback),
|
| - weak_ptr_factory_(this) {}
|
| -
|
| -InitializeStoreTask::~InitializeStoreTask() {}
|
| -
|
| -void InitializeStoreTask::Run() {
|
| - InitializeStore();
|
| -}
|
| -
|
| -void InitializeStoreTask::InitializeStore() {
|
| - store_->Initialize(base::Bind(&InitializeStoreTask::CompleteIfSuccessful,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void InitializeStoreTask::CompleteIfSuccessful(bool success) {
|
| - if (success) {
|
| - callback_.Run(true);
|
| - TaskComplete();
|
| - return;
|
| - }
|
| -
|
| - TryToResetStore();
|
| -}
|
| -
|
| -void InitializeStoreTask::TryToResetStore() {
|
| - if (reset_attempts_left_ == 0) {
|
| - callback_.Run(false);
|
| - TaskComplete();
|
| - return;
|
| - }
|
| -
|
| - reset_attempts_left_--;
|
| - store_->Reset(base::Bind(&InitializeStoreTask::OnStoreResetDone,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void InitializeStoreTask::OnStoreResetDone(bool success) {
|
| - if (success)
|
| - InitializeStore();
|
| - else
|
| - TryToResetStore();
|
| -}
|
| -
|
| -} // namespace offline_pages
|
|
|