| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // The AllStatus object watches various sync engine components and aggregates | |
| 6 // the status of all of them into one place. | |
| 7 | |
| 8 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_ALL_STATUS_H_ | |
| 9 #define CHROME_BROWSER_SYNC_INTERNAL_API_ALL_STATUS_H_ | |
| 10 #pragma once | |
| 11 | |
| 12 #include <map> | |
| 13 | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/synchronization/lock.h" | |
| 17 #include "chrome/browser/sync/internal_api/sync_manager.h" | |
| 18 #include "sync/engine/syncer_types.h" | |
| 19 #include "sync/syncable/model_type.h" | |
| 20 | |
| 21 namespace browser_sync { | |
| 22 | |
| 23 class ScopedStatusLock; | |
| 24 struct ServerConnectionEvent; | |
| 25 | |
| 26 // TODO(rlarocque): | |
| 27 // Most of this data ends up on the about:sync page. But the page is only | |
| 28 // 'pinged' to update itself at the end of a sync cycle. A user could refresh | |
| 29 // manually, but unless their timing is excellent it's unlikely that a user will | |
| 30 // see any state in mid-sync cycle. We have no plans to change this. | |
| 31 // | |
| 32 // What we do intend to do is improve the UI so that changes following a sync | |
| 33 // cycle are more visible. Without such a change, the status summary for a | |
| 34 // healthy syncer will constantly display as "READY" and never provide any | |
| 35 // indication of a sync cycle being performed. See crbug.com/108100. | |
| 36 | |
| 37 class AllStatus : public SyncEngineEventListener { | |
| 38 friend class ScopedStatusLock; | |
| 39 public: | |
| 40 AllStatus(); | |
| 41 virtual ~AllStatus(); | |
| 42 | |
| 43 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE; | |
| 44 | |
| 45 sync_api::SyncManager::Status status() const; | |
| 46 | |
| 47 void SetNotificationsEnabled(bool notifications_enabled); | |
| 48 | |
| 49 void IncrementNotifiableCommits(); | |
| 50 | |
| 51 void IncrementNotificationsReceived(); | |
| 52 | |
| 53 void SetEncryptedTypes(syncable::ModelTypeSet types); | |
| 54 void SetCryptographerReady(bool ready); | |
| 55 void SetCryptoHasPendingKeys(bool has_pending_keys); | |
| 56 | |
| 57 void SetUniqueId(const std::string& guid); | |
| 58 | |
| 59 protected: | |
| 60 // Examines syncer to calculate syncing and the unsynced count, | |
| 61 // and returns a Status with new values. | |
| 62 sync_api::SyncManager::Status CalcSyncing(const SyncEngineEvent& event) const; | |
| 63 sync_api::SyncManager::Status CreateBlankStatus() const; | |
| 64 | |
| 65 sync_api::SyncManager::Status status_; | |
| 66 | |
| 67 mutable base::Lock mutex_; // Protects all data members. | |
| 68 DISALLOW_COPY_AND_ASSIGN(AllStatus); | |
| 69 }; | |
| 70 | |
| 71 class ScopedStatusLock { | |
| 72 public: | |
| 73 explicit ScopedStatusLock(AllStatus* allstatus); | |
| 74 ~ScopedStatusLock(); | |
| 75 protected: | |
| 76 AllStatus* allstatus_; | |
| 77 }; | |
| 78 | |
| 79 } // namespace browser_sync | |
| 80 | |
| 81 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_ALL_STATUS_H_ | |
| OLD | NEW |