| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/engine/all_status.h" | 5 #include "chrome/browser/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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace browser_sync { | 23 namespace browser_sync { |
| 24 | 24 |
| 25 static const time_t kMinSyncObserveInterval = 10; // seconds | 25 static const time_t kMinSyncObserveInterval = 10; // seconds |
| 26 | 26 |
| 27 // Backoff interval randomization factor. | 27 // Backoff interval randomization factor. |
| 28 static const int kBackoffRandomizationFactor = 2; | 28 static const int kBackoffRandomizationFactor = 2; |
| 29 | 29 |
| 30 const char* AllStatus::GetSyncStatusString(SyncStatus icon) { | 30 const char* AllStatus::GetSyncStatusString(SyncStatus icon) { |
| 31 const char* strings[] = {"OFFLINE", "OFFLINE_UNSYNCED", "SYNCING", "READY", | 31 const char* strings[] = {"OFFLINE", "OFFLINE_UNSYNCED", "SYNCING", "READY", |
| 32 "CONFLICT", "OFFLINE_UNUSABLE"}; | 32 "CONFLICT", "OFFLINE_UNUSABLE"}; |
| 33 COMPILE_ASSERT(ARRAYSIZE(strings) == ICON_STATUS_COUNT, enum_indexed_array); | 33 COMPILE_ASSERT(arraysize(strings) == ICON_STATUS_COUNT, enum_indexed_array); |
| 34 if (icon < 0 || icon >= ARRAYSIZE(strings)) | 34 if (icon < 0 || icon >= static_cast<SyncStatus>(arraysize(strings))) |
| 35 LOG(FATAL) << "Illegal Icon State:" << icon; | 35 LOG(FATAL) << "Illegal Icon State:" << icon; |
| 36 return strings[icon]; | 36 return strings[icon]; |
| 37 } | 37 } |
| 38 | 38 |
| 39 static const AllStatus::Status init_status = | 39 static const AllStatus::Status init_status = |
| 40 { AllStatus::OFFLINE }; | 40 { AllStatus::OFFLINE }; |
| 41 | 41 |
| 42 static const AllStatusEvent shutdown_event = | 42 static const AllStatusEvent shutdown_event = |
| 43 { AllStatusEvent::SHUTDOWN, init_status }; | 43 { AllStatusEvent::SHUTDOWN, init_status }; |
| 44 | 44 |
| 45 AllStatus::AllStatus() : channel_(new Channel(shutdown_event)), | 45 AllStatus::AllStatus() : status_(init_status), |
| 46 status_(init_status) { | 46 channel_(new Channel(shutdown_event)) { |
| 47 status_.initial_sync_ended = true; | 47 status_.initial_sync_ended = true; |
| 48 status_.notifications_enabled = false; | 48 status_.notifications_enabled = false; |
| 49 } | 49 } |
| 50 | 50 |
| 51 AllStatus::~AllStatus() { | 51 AllStatus::~AllStatus() { |
| 52 delete channel_; | 52 delete channel_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void AllStatus::WatchConnectionManager(ServerConnectionManager* conn_mgr) { | 55 void AllStatus::WatchConnectionManager(ServerConnectionManager* conn_mgr) { |
| 56 conn_mgr_hookup_.reset(NewEventListenerHookup(conn_mgr->channel(), this, | 56 conn_mgr_hookup_.reset(NewEventListenerHookup(conn_mgr->channel(), this, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 allstatus_->mutex_.Unlock(); | 326 allstatus_->mutex_.Unlock(); |
| 327 if (event_.what_changed) | 327 if (event_.what_changed) |
| 328 allstatus_->channel()->NotifyListeners(event_); | 328 allstatus_->channel()->NotifyListeners(event_); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void ScopedStatusLockWithNotify::NotifyOverQuota() { | 331 void ScopedStatusLockWithNotify::NotifyOverQuota() { |
| 332 event_.what_changed |= AllStatusEvent::OVER_QUOTA; | 332 event_.what_changed |= AllStatusEvent::OVER_QUOTA; |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace browser_sync | 335 } // namespace browser_sync |
| OLD | NEW |