Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: components/offline_pages/background/initialize_store_task.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698