Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sync/engine/all_status.cc

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/all_status.h ('k') | sync/engine/apply_updates_command.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "sync/engine/all_status.h" 5 #include "sync/engine/all_status.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/port.h" 10 #include "base/port.h"
11 #include "sync/engine/net/server_connection_manager.h" 11 #include "sync/engine/net/server_connection_manager.h"
12 #include "sync/internal_api/public/base/model_type.h" 12 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/sessions/session_state.h" 13 #include "sync/sessions/session_state.h"
14 14
15 namespace syncer { 15 namespace syncer {
16 16
17 AllStatus::AllStatus() { 17 AllStatus::AllStatus() {
18 status_.initial_sync_ended = true; 18 status_.initial_sync_ended = true;
19 status_.notifications_enabled = false; 19 status_.notifications_enabled = false;
20 status_.cryptographer_ready = false; 20 status_.cryptographer_ready = false;
21 status_.crypto_has_pending_keys = false; 21 status_.crypto_has_pending_keys = false;
22 } 22 }
23 23
24 AllStatus::~AllStatus() { 24 AllStatus::~AllStatus() {
25 } 25 }
26 26
27 syncer::SyncStatus AllStatus::CreateBlankStatus() const { 27 SyncStatus AllStatus::CreateBlankStatus() const {
28 // Status is initialized with the previous status value. Variables 28 // Status is initialized with the previous status value. Variables
29 // whose values accumulate (e.g. lifetime counters like updates_received) 29 // whose values accumulate (e.g. lifetime counters like updates_received)
30 // are not to be cleared here. 30 // are not to be cleared here.
31 syncer::SyncStatus status = status_; 31 SyncStatus status = status_;
32 status.encryption_conflicts = 0; 32 status.encryption_conflicts = 0;
33 status.hierarchy_conflicts = 0; 33 status.hierarchy_conflicts = 0;
34 status.simple_conflicts = 0; 34 status.simple_conflicts = 0;
35 status.server_conflicts = 0; 35 status.server_conflicts = 0;
36 status.committed_count = 0; 36 status.committed_count = 0;
37 status.initial_sync_ended = false; 37 status.initial_sync_ended = false;
38 status.updates_available = 0; 38 status.updates_available = 0;
39 return status; 39 return status;
40 } 40 }
41 41
42 syncer::SyncStatus AllStatus::CalcSyncing( 42 SyncStatus AllStatus::CalcSyncing(const SyncEngineEvent &event) const {
43 const SyncEngineEvent &event) const { 43 SyncStatus status = CreateBlankStatus();
44 syncer::SyncStatus status = CreateBlankStatus();
45 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; 44 const sessions::SyncSessionSnapshot& snapshot = event.snapshot;
46 status.encryption_conflicts = snapshot.num_encryption_conflicts(); 45 status.encryption_conflicts = snapshot.num_encryption_conflicts();
47 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); 46 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts();
48 status.simple_conflicts = snapshot.num_simple_conflicts(); 47 status.simple_conflicts = snapshot.num_simple_conflicts();
49 status.server_conflicts = snapshot.num_server_conflicts(); 48 status.server_conflicts = snapshot.num_server_conflicts();
50 status.committed_count = 49 status.committed_count =
51 snapshot.model_neutral_state().num_successful_commits; 50 snapshot.model_neutral_state().num_successful_commits;
52 51
53 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_BEGIN) { 52 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_BEGIN) {
54 status.syncing = true; 53 status.syncing = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 status_ = CreateBlankStatus(); 112 status_ = CreateBlankStatus();
114 status_.sync_protocol_error = 113 status_.sync_protocol_error =
115 event.snapshot.model_neutral_state().sync_protocol_error; 114 event.snapshot.model_neutral_state().sync_protocol_error;
116 break; 115 break;
117 default: 116 default:
118 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened; 117 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened;
119 break; 118 break;
120 } 119 }
121 } 120 }
122 121
123 syncer::SyncStatus AllStatus::status() const { 122 SyncStatus AllStatus::status() const {
124 base::AutoLock lock(mutex_); 123 base::AutoLock lock(mutex_);
125 return status_; 124 return status_;
126 } 125 }
127 126
128 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) { 127 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) {
129 ScopedStatusLock lock(this); 128 ScopedStatusLock lock(this);
130 status_.notifications_enabled = notifications_enabled; 129 status_.notifications_enabled = notifications_enabled;
131 } 130 }
132 131
133 void AllStatus::IncrementNotificationsReceived() { 132 void AllStatus::IncrementNotificationsReceived() {
134 ScopedStatusLock lock(this); 133 ScopedStatusLock lock(this);
135 ++status_.notifications_received; 134 ++status_.notifications_received;
136 } 135 }
137 136
138 void AllStatus::SetEncryptedTypes(syncer::ModelTypeSet types) { 137 void AllStatus::SetEncryptedTypes(ModelTypeSet types) {
139 ScopedStatusLock lock(this); 138 ScopedStatusLock lock(this);
140 status_.encrypted_types = types; 139 status_.encrypted_types = types;
141 } 140 }
142 141
143 void AllStatus::SetThrottledTypes(const syncer::ModelTypeSet& types) { 142 void AllStatus::SetThrottledTypes(const ModelTypeSet& types) {
144 ScopedStatusLock lock(this); 143 ScopedStatusLock lock(this);
145 status_.throttled_types = types; 144 status_.throttled_types = types;
146 } 145 }
147 146
148 void AllStatus::SetCryptographerReady(bool ready) { 147 void AllStatus::SetCryptographerReady(bool ready) {
149 ScopedStatusLock lock(this); 148 ScopedStatusLock lock(this);
150 status_.cryptographer_ready = ready; 149 status_.cryptographer_ready = ready;
151 } 150 }
152 151
153 void AllStatus::SetCryptoHasPendingKeys(bool has_pending_keys) { 152 void AllStatus::SetCryptoHasPendingKeys(bool has_pending_keys) {
154 ScopedStatusLock lock(this); 153 ScopedStatusLock lock(this);
155 status_.crypto_has_pending_keys = has_pending_keys; 154 status_.crypto_has_pending_keys = has_pending_keys;
156 } 155 }
157 156
158 void AllStatus::SetUniqueId(const std::string& guid) { 157 void AllStatus::SetUniqueId(const std::string& guid) {
159 ScopedStatusLock lock(this); 158 ScopedStatusLock lock(this);
160 status_.unique_id = guid; 159 status_.unique_id = guid;
161 } 160 }
162 161
163 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) 162 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus)
164 : allstatus_(allstatus) { 163 : allstatus_(allstatus) {
165 allstatus->mutex_.Acquire(); 164 allstatus->mutex_.Acquire();
166 } 165 }
167 166
168 ScopedStatusLock::~ScopedStatusLock() { 167 ScopedStatusLock::~ScopedStatusLock() {
169 allstatus_->mutex_.Release(); 168 allstatus_->mutex_.Release();
170 } 169 }
171 170
172 } // namespace syncer 171 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/all_status.h ('k') | sync/engine/apply_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698