OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 5 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // the tasks we want to run. | 32 // the tasks we want to run. |
33 class RunTaskOnHistoryThread : public history::HistoryDBTask { | 33 class RunTaskOnHistoryThread : public history::HistoryDBTask { |
34 public: | 34 public: |
35 explicit RunTaskOnHistoryThread(const base::Closure& task, | 35 explicit RunTaskOnHistoryThread(const base::Closure& task, |
36 TypedUrlDataTypeController* dtc) | 36 TypedUrlDataTypeController* dtc) |
37 : task_(new base::Closure(task)), | 37 : task_(new base::Closure(task)), |
38 dtc_(dtc) { | 38 dtc_(dtc) { |
39 } | 39 } |
40 | 40 |
41 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 41 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
42 history::HistoryDatabase* db) OVERRIDE { | 42 history::HistoryDatabase* db) override { |
43 // Set the backend, then release our reference before executing the task. | 43 // Set the backend, then release our reference before executing the task. |
44 dtc_->SetBackend(backend); | 44 dtc_->SetBackend(backend); |
45 dtc_ = NULL; | 45 dtc_ = NULL; |
46 | 46 |
47 // Invoke the task, then free it immediately so we don't keep a reference | 47 // Invoke the task, then free it immediately so we don't keep a reference |
48 // around all the way until DoneRunOnMainThread() is invoked back on the | 48 // around all the way until DoneRunOnMainThread() is invoked back on the |
49 // main thread - we want to release references as soon as possible to avoid | 49 // main thread - we want to release references as soon as possible to avoid |
50 // keeping them around too long during shutdown. | 50 // keeping them around too long during shutdown. |
51 task_->Run(); | 51 task_->Run(); |
52 task_.reset(); | 52 task_.reset(); |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 virtual void DoneRunOnMainThread() OVERRIDE {} | 56 virtual void DoneRunOnMainThread() override {} |
57 | 57 |
58 protected: | 58 protected: |
59 virtual ~RunTaskOnHistoryThread() {} | 59 virtual ~RunTaskOnHistoryThread() {} |
60 | 60 |
61 scoped_ptr<base::Closure> task_; | 61 scoped_ptr<base::Closure> task_; |
62 scoped_refptr<TypedUrlDataTypeController> dtc_; | 62 scoped_refptr<TypedUrlDataTypeController> dtc_; |
63 }; | 63 }; |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 void TypedUrlDataTypeController::DisconnectProcessor( | 154 void TypedUrlDataTypeController::DisconnectProcessor( |
155 sync_driver::ChangeProcessor* processor) { | 155 sync_driver::ChangeProcessor* processor) { |
156 static_cast<TypedUrlChangeProcessor*>(processor)->Disconnect(); | 156 static_cast<TypedUrlChangeProcessor*>(processor)->Disconnect(); |
157 } | 157 } |
158 | 158 |
159 TypedUrlDataTypeController::~TypedUrlDataTypeController() {} | 159 TypedUrlDataTypeController::~TypedUrlDataTypeController() {} |
160 | 160 |
161 } // namespace browser_sync | 161 } // namespace browser_sync |
OLD | NEW |