OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_file_system/drive_backend/fake_sync_worker.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/values.h" | 9 #include "base/values.h" |
8 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" | 10 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" |
9 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" | 11 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" |
10 #include "chrome/browser/sync_file_system/sync_status_code.h" | 12 #include "chrome/browser/sync_file_system/sync_status_code.h" |
11 | 13 |
12 namespace sync_file_system { | 14 namespace sync_file_system { |
13 namespace drive_backend { | 15 namespace drive_backend { |
14 | 16 |
15 FakeSyncWorker::FakeSyncWorker() | 17 FakeSyncWorker::FakeSyncWorker() |
16 : sync_enabled_(true) { | 18 : sync_enabled_(true) { |
17 sequence_checker_.DetachFromSequence(); | 19 sequence_checker_.DetachFromSequence(); |
18 } | 20 } |
19 | 21 |
20 FakeSyncWorker::~FakeSyncWorker() { | 22 FakeSyncWorker::~FakeSyncWorker() { |
21 observers_.Clear(); | 23 observers_.Clear(); |
22 } | 24 } |
23 | 25 |
24 void FakeSyncWorker::Initialize( | 26 void FakeSyncWorker::Initialize( |
25 scoped_ptr<SyncEngineContext> sync_engine_context) { | 27 scoped_ptr<SyncEngineContext> sync_engine_context) { |
26 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 28 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
27 | 29 |
28 sync_engine_context_ = sync_engine_context.Pass(); | 30 sync_engine_context_ = std::move(sync_engine_context); |
29 status_map_.clear(); | 31 status_map_.clear(); |
30 // TODO(peria): Set |status_map_| as a fake metadata database. | 32 // TODO(peria): Set |status_map_| as a fake metadata database. |
31 } | 33 } |
32 | 34 |
33 void FakeSyncWorker::RegisterOrigin(const GURL& origin, | 35 void FakeSyncWorker::RegisterOrigin(const GURL& origin, |
34 const SyncStatusCallback& callback) { | 36 const SyncStatusCallback& callback) { |
35 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 37 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
36 // TODO(peria): Check how it should act on installing installed app? | 38 // TODO(peria): Check how it should act on installing installed app? |
37 status_map_[origin] = REGISTERED; | 39 status_map_[origin] = REGISTERED; |
38 callback.Run(SYNC_STATUS_OK); | 40 callback.Run(SYNC_STATUS_OK); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 (*status_map)[itr->first] = "Disabled"; | 100 (*status_map)[itr->first] = "Disabled"; |
99 break; | 101 break; |
100 case UNINSTALLED: | 102 case UNINSTALLED: |
101 (*status_map)[itr->first] = "Uninstalled"; | 103 (*status_map)[itr->first] = "Uninstalled"; |
102 break; | 104 break; |
103 default: | 105 default: |
104 (*status_map)[itr->first] = "Unknown"; | 106 (*status_map)[itr->first] = "Unknown"; |
105 break; | 107 break; |
106 } | 108 } |
107 } | 109 } |
108 callback.Run(status_map.Pass()); | 110 callback.Run(std::move(status_map)); |
109 } | 111 } |
110 | 112 |
111 scoped_ptr<base::ListValue> FakeSyncWorker::DumpFiles(const GURL& origin) { | 113 scoped_ptr<base::ListValue> FakeSyncWorker::DumpFiles(const GURL& origin) { |
112 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 114 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
113 return nullptr; | 115 return nullptr; |
114 } | 116 } |
115 | 117 |
116 scoped_ptr<base::ListValue> FakeSyncWorker::DumpDatabase() { | 118 scoped_ptr<base::ListValue> FakeSyncWorker::DumpDatabase() { |
117 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 119 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
118 return nullptr; | 120 return nullptr; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 const std::string& description) { | 172 const std::string& description) { |
171 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 173 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
172 | 174 |
173 FOR_EACH_OBSERVER( | 175 FOR_EACH_OBSERVER( |
174 Observer, observers_, | 176 Observer, observers_, |
175 UpdateServiceState(state, description)); | 177 UpdateServiceState(state, description)); |
176 } | 178 } |
177 | 179 |
178 } // namespace drive_backend | 180 } // namespace drive_backend |
179 } // namespace sync_file_system | 181 } // namespace sync_file_system |
OLD | NEW |