| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 RequestQueueStoreSQL::~RequestQueueStoreSQL() { | 433 RequestQueueStoreSQL::~RequestQueueStoreSQL() { |
| 434 if (db_.get()) | 434 if (db_.get()) |
| 435 background_task_runner_->DeleteSoon(FROM_HERE, db_.release()); | 435 background_task_runner_->DeleteSoon(FROM_HERE, db_.release()); |
| 436 } | 436 } |
| 437 | 437 |
| 438 bool RequestQueueStoreSQL::CheckDb(const base::Closure& callback) { | 438 bool RequestQueueStoreSQL::CheckDb(const base::Closure& callback) { |
| 439 DCHECK(db_.get()); | 439 DCHECK(db_.get()); |
| 440 if (!db_.get()) { | 440 if (!db_.get()) { |
| 441 // Nothing to do, but post a callback instead of calling directly | 441 // Nothing to do, but post a callback instead of calling directly |
| 442 // to preserve the async style behavior to prevent bugs. | 442 // to preserve the async style behavior to prevent bugs. |
| 443 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 443 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 444 base::Bind(callback)); | |
| 445 return false; | 444 return false; |
| 446 } | 445 } |
| 447 return true; | 446 return true; |
| 448 } | 447 } |
| 449 | 448 |
| 450 void RequestQueueStoreSQL::GetRequests(const GetRequestsCallback& callback) { | 449 void RequestQueueStoreSQL::GetRequests(const GetRequestsCallback& callback) { |
| 451 DCHECK(db_.get()); | 450 DCHECK(db_.get()); |
| 452 std::vector<std::unique_ptr<SavePageRequest>> requests; | 451 std::vector<std::unique_ptr<SavePageRequest>> requests; |
| 453 if (!CheckDb(base::Bind(callback, false, base::Passed(&requests)))) | 452 if (!CheckDb(base::Bind(callback, false, base::Passed(&requests)))) |
| 454 return; | 453 return; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 554 } |
| 556 | 555 |
| 557 void RequestQueueStoreSQL::OnResetDone(const ResetCallback& callback, | 556 void RequestQueueStoreSQL::OnResetDone(const ResetCallback& callback, |
| 558 bool success) { | 557 bool success) { |
| 559 // Complete connection initialization post reset. | 558 // Complete connection initialization post reset. |
| 560 OnOpenConnectionDone(success); | 559 OnOpenConnectionDone(success); |
| 561 callback.Run(success); | 560 callback.Run(success); |
| 562 } | 561 } |
| 563 | 562 |
| 564 } // namespace offline_pages | 563 } // namespace offline_pages |
| OLD | NEW |