| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 if (success) | 362 if (success) |
| 363 success = InitDatabase(db, db_file_path); | 363 success = InitDatabase(db, db_file_path); |
| 364 runner->PostTask(FROM_HERE, base::Bind(callback, success)); | 364 runner->PostTask(FROM_HERE, base::Bind(callback, success)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool RequestQueueStoreSQL::CheckDb(const base::Closure& callback) { | 367 bool RequestQueueStoreSQL::CheckDb(const base::Closure& callback) { |
| 368 DCHECK(db_.get()); | 368 DCHECK(db_.get()); |
| 369 if (!db_.get()) { | 369 if (!db_.get()) { |
| 370 // Nothing to do, but post a callback instead of calling directly | 370 // Nothing to do, but post a callback instead of calling directly |
| 371 // to preserve the async style behavior to prevent bugs. | 371 // to preserve the async style behavior to prevent bugs. |
| 372 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 372 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 373 base::Bind(callback)); | |
| 374 return false; | 373 return false; |
| 375 } | 374 } |
| 376 return true; | 375 return true; |
| 377 } | 376 } |
| 378 | 377 |
| 379 void RequestQueueStoreSQL::GetRequests(const GetRequestsCallback& callback) { | 378 void RequestQueueStoreSQL::GetRequests(const GetRequestsCallback& callback) { |
| 380 DCHECK(db_.get()); | 379 DCHECK(db_.get()); |
| 381 std::vector<std::unique_ptr<SavePageRequest>> requests; | 380 std::vector<std::unique_ptr<SavePageRequest>> requests; |
| 382 if (!CheckDb(base::Bind(callback, false, base::Passed(&requests)))) | 381 if (!CheckDb(base::Bind(callback, false, base::Passed(&requests)))) |
| 383 return; | 382 return; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 470 } |
| 472 | 471 |
| 473 void RequestQueueStoreSQL::OnResetDone(const ResetCallback& callback, | 472 void RequestQueueStoreSQL::OnResetDone(const ResetCallback& callback, |
| 474 bool success) { | 473 bool success) { |
| 475 // Complete connection initialization post reset. | 474 // Complete connection initialization post reset. |
| 476 OnOpenConnectionDone(success); | 475 OnOpenConnectionDone(success); |
| 477 callback.Run(success); | 476 callback.Run(success); |
| 478 } | 477 } |
| 479 | 478 |
| 480 } // namespace offline_pages | 479 } // namespace offline_pages |
| OLD | NEW |