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

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

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

Powered by Google App Engine
This is Rietveld 408576698