| OLD | NEW |
| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 void ResetSync(sql::Connection* db, | 348 void ResetSync(sql::Connection* db, |
| 349 const base::FilePath& db_file_path, | 349 const base::FilePath& db_file_path, |
| 350 scoped_refptr<base::SingleThreadTaskRunner> runner, | 350 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 351 const StoreStateCallback& callback) { | 351 const StoreStateCallback& callback) { |
| 352 // This method deletes the content of the whole store and reinitializes it. | 352 // This method deletes the content of the whole store and reinitializes it. |
| 353 bool success = db->Raze(); | 353 bool success = db->Raze(); |
| 354 db->Close(); | 354 db->Close(); |
| 355 StoreState state; | 355 StoreState state; |
| 356 if (!success) | 356 if (!success) |
| 357 state = StoreState::FAILED_RESET; | 357 state = StoreState::FAILED_RESET; |
| 358 if (InitDatabase(db, db_file_path)) | 358 else if (InitDatabase(db, db_file_path)) |
| 359 state = StoreState::LOADED; | 359 state = StoreState::LOADED; |
| 360 else | 360 else |
| 361 state = StoreState::FAILED_LOADING; | 361 state = StoreState::FAILED_LOADING; |
| 362 | 362 |
| 363 runner->PostTask(FROM_HERE, base::Bind(callback, state)); | 363 runner->PostTask(FROM_HERE, base::Bind(callback, state)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // anonymous namespace | 366 } // anonymous namespace |
| 367 | 367 |
| 368 RequestQueueStoreSQL::RequestQueueStoreSQL( | 368 RequestQueueStoreSQL::RequestQueueStoreSQL( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // Complete connection initialization post reset. | 488 // Complete connection initialization post reset. |
| 489 OnOpenConnectionDone(state); | 489 OnOpenConnectionDone(state); |
| 490 callback.Run(state == StoreState::LOADED); | 490 callback.Run(state == StoreState::LOADED); |
| 491 } | 491 } |
| 492 | 492 |
| 493 StoreState RequestQueueStoreSQL::state() const { | 493 StoreState RequestQueueStoreSQL::state() const { |
| 494 return state_; | 494 return state_; |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace offline_pages | 497 } // namespace offline_pages |
| OLD | NEW |