| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser_sync/signin_confirmation_helper.h" | 5 #include "components/browser_sync/signin_confirmation_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "components/history/core/browser/history_backend.h" | 11 #include "components/history/core/browser/history_backend.h" |
| 12 #include "components/history/core/browser/history_db_task.h" | 12 #include "components/history/core/browser/history_db_task.h" |
| 13 #include "components/history/core/browser/history_service.h" | 13 #include "components/history/core/browser/history_service.h" |
| 14 #include "components/history/core/browser/history_types.h" | 14 #include "components/history/core/browser/history_types.h" |
| 15 | 15 |
| 16 namespace browser_sync { |
| 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 // Determines whether there are any typed URLs in a history backend. | 20 // Determines whether there are any typed URLs in a history backend. |
| 19 class HasTypedURLsTask : public history::HistoryDBTask { | 21 class HasTypedURLsTask : public history::HistoryDBTask { |
| 20 public: | 22 public: |
| 21 explicit HasTypedURLsTask(const base::Callback<void(bool)>& cb) | 23 explicit HasTypedURLsTask(const base::Callback<void(bool)>& cb) |
| 22 : has_typed_urls_(false), cb_(cb) {} | 24 : has_typed_urls_(false), cb_(cb) {} |
| 23 | 25 |
| 24 bool RunOnDBThread(history::HistoryBackend* backend, | 26 bool RunOnDBThread(history::HistoryBackend* backend, |
| 25 history::HistoryDatabase* db) override { | 27 history::HistoryDatabase* db) override { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 ~HasTypedURLsTask() override {} | 41 ~HasTypedURLsTask() override {} |
| 40 | 42 |
| 41 bool has_typed_urls_; | 43 bool has_typed_urls_; |
| 42 base::Callback<void(bool)> cb_; | 44 base::Callback<void(bool)> cb_; |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 } // namespace | 47 } // namespace |
| 46 | 48 |
| 47 namespace sync_driver { | |
| 48 | |
| 49 SigninConfirmationHelper::SigninConfirmationHelper( | 49 SigninConfirmationHelper::SigninConfirmationHelper( |
| 50 history::HistoryService* history_service, | 50 history::HistoryService* history_service, |
| 51 const base::Callback<void(bool)>& return_result) | 51 const base::Callback<void(bool)>& return_result) |
| 52 : origin_thread_(base::ThreadTaskRunnerHandle::Get()), | 52 : origin_thread_(base::ThreadTaskRunnerHandle::Get()), |
| 53 history_service_(history_service), | 53 history_service_(history_service), |
| 54 pending_requests_(0), | 54 pending_requests_(0), |
| 55 return_result_(return_result) {} | 55 return_result_(return_result) {} |
| 56 | 56 |
| 57 SigninConfirmationHelper::~SigninConfirmationHelper() { | 57 SigninConfirmationHelper::~SigninConfirmationHelper() { |
| 58 DCHECK(origin_thread_->BelongsToCurrentThread()); | 58 DCHECK(origin_thread_->BelongsToCurrentThread()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // result of |true|, otherwise pass the last returned result. | 110 // result of |true|, otherwise pass the last returned result. |
| 111 if (--pending_requests_ == 0 || result) { | 111 if (--pending_requests_ == 0 || result) { |
| 112 return_result_.Run(result); | 112 return_result_.Run(result); |
| 113 | 113 |
| 114 // This leaks at shutdown if the HistoryService is destroyed, but | 114 // This leaks at shutdown if the HistoryService is destroyed, but |
| 115 // the process is going to die anyway. | 115 // the process is going to die anyway. |
| 116 delete this; | 116 delete this; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace sync_driver | 120 } // namespace browser_sync |
| OLD | NEW |