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

Side by Side Diff: components/offline_pages/background/request_queue_store_sql.cc

Issue 2384423003: [Offline pages] Resetting offline page metadata store if initial load fails (Closed)
Patch Set: Rebased and comments addressed Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/request_queue_store_sql.h" 5 #include "components/offline_pages/background/request_queue_store_sql.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void ResetSync(sql::Connection* db, 332 void ResetSync(sql::Connection* db,
333 const base::FilePath& db_file_path, 333 const base::FilePath& db_file_path,
334 scoped_refptr<base::SingleThreadTaskRunner> runner, 334 scoped_refptr<base::SingleThreadTaskRunner> runner,
335 const StoreStateCallback& callback) { 335 const StoreStateCallback& callback) {
336 // This method deletes the content of the whole store and reinitializes it. 336 // This method deletes the content of the whole store and reinitializes it.
337 bool success = db->Raze(); 337 bool success = db->Raze();
338 db->Close(); 338 db->Close();
339 StoreState state; 339 StoreState state;
340 if (!success) 340 if (!success)
341 state = StoreState::FAILED_RESET; 341 state = StoreState::FAILED_RESET;
342 if (InitDatabase(db, db_file_path)) 342 else if (InitDatabase(db, db_file_path))
343 state = StoreState::LOADED; 343 state = StoreState::LOADED;
344 else 344 else
345 state = StoreState::FAILED_LOADING; 345 state = StoreState::FAILED_LOADING;
346 346
347 runner->PostTask(FROM_HERE, base::Bind(callback, state)); 347 runner->PostTask(FROM_HERE, base::Bind(callback, state));
348 } 348 }
349 349
350 } // anonymous namespace 350 } // anonymous namespace
351 351
352 RequestQueueStoreSQL::RequestQueueStoreSQL( 352 RequestQueueStoreSQL::RequestQueueStoreSQL(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // Complete connection initialization post reset. 465 // Complete connection initialization post reset.
466 OnOpenConnectionDone(state); 466 OnOpenConnectionDone(state);
467 callback.Run(state == StoreState::LOADED); 467 callback.Run(state == StoreState::LOADED);
468 } 468 }
469 469
470 StoreState RequestQueueStoreSQL::state() const { 470 StoreState RequestQueueStoreSQL::state() const {
471 return state_; 471 return state_;
472 } 472 }
473 473
474 } // namespace offline_pages 474 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698