| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |