OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/sync/driver/glue/sync_backend_registrar.h" | 5 #include "components/sync/driver/glue/sync_backend_registrar.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "components/sync/driver/change_processor.h" | 14 #include "components/sync/driver/change_processor.h" |
14 #include "components/sync/driver/sync_client.h" | 15 #include "components/sync/driver/sync_client.h" |
15 #include "components/sync/syncable/user_share.h" | 16 #include "components/sync/syncable/user_share.h" |
16 | 17 |
17 namespace syncer { | 18 namespace syncer { |
18 | 19 |
19 SyncBackendRegistrar::SyncBackendRegistrar( | 20 SyncBackendRegistrar::SyncBackendRegistrar( |
20 const std::string& name, | 21 const std::string& name, |
21 SyncClient* sync_client, | 22 SyncClient* sync_client, |
22 std::unique_ptr<base::Thread> sync_thread, | 23 std::unique_ptr<base::Thread> sync_thread, |
23 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 24 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
24 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 25 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
25 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread) | 26 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread) |
26 : name_(name), | 27 : name_(name), |
27 sync_client_(sync_client), | 28 sync_client_(sync_client), |
28 ui_thread_(ui_thread), | 29 ui_thread_(ui_thread), |
29 db_thread_(db_thread), | 30 db_thread_(db_thread), |
30 file_thread_(file_thread) { | 31 file_thread_(file_thread) { |
31 DCHECK(ui_thread_->BelongsToCurrentThread()); | 32 DCHECK(ui_thread_->BelongsToCurrentThread()); |
32 DCHECK(sync_client_); | 33 DCHECK(sync_client_); |
33 | 34 |
34 sync_thread_ = std::move(sync_thread); | 35 sync_thread_ = std::move(sync_thread); |
35 if (!sync_thread_) { | 36 if (!sync_thread_) { |
36 sync_thread_.reset(new base::Thread("Chrome_SyncThread")); | 37 sync_thread_ = base::MakeUnique<base::Thread>("Chrome_SyncThread"); |
37 base::Thread::Options options; | 38 base::Thread::Options options; |
38 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 39 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
39 CHECK(sync_thread_->StartWithOptions(options)); | 40 CHECK(sync_thread_->StartWithOptions(options)); |
40 } | 41 } |
41 | 42 |
42 MaybeAddWorker(GROUP_DB); | 43 MaybeAddWorker(GROUP_DB); |
43 MaybeAddWorker(GROUP_FILE); | 44 MaybeAddWorker(GROUP_FILE); |
44 MaybeAddWorker(GROUP_UI); | 45 MaybeAddWorker(GROUP_UI); |
45 MaybeAddWorker(GROUP_PASSIVE); | 46 MaybeAddWorker(GROUP_PASSIVE); |
46 MaybeAddWorker(GROUP_HISTORY); | 47 MaybeAddWorker(GROUP_HISTORY); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 base::Thread* SyncBackendRegistrar::sync_thread() { | 374 base::Thread* SyncBackendRegistrar::sync_thread() { |
374 return sync_thread_.get(); | 375 return sync_thread_.get(); |
375 } | 376 } |
376 | 377 |
377 ModelSafeGroup SyncBackendRegistrar::GetInitialGroupForType( | 378 ModelSafeGroup SyncBackendRegistrar::GetInitialGroupForType( |
378 ModelType type) const { | 379 ModelType type) const { |
379 return non_blocking_types_.Has(type) ? GROUP_NON_BLOCKING : GROUP_PASSIVE; | 380 return non_blocking_types_.Has(type) ? GROUP_NON_BLOCKING : GROUP_PASSIVE; |
380 } | 381 } |
381 | 382 |
382 } // namespace syncer | 383 } // namespace syncer |
OLD | NEW |