Make sure webview uses embedder display DPI.
[chromium-blink-merge.git] / sync / engine / all_status.h
blob76ce3073d521e9b68c31f279925ca70d44d2485e
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.
8 #ifndef SYNC_INTERNAL_API_ALL_STATUS_H_
9 #define SYNC_INTERNAL_API_ALL_STATUS_H_
11 #include <map>
12 #include <string>
14 #include "base/compiler_specific.h"
15 #include "base/synchronization/lock.h"
16 #include "sync/engine/sync_engine_event.h"
17 #include "sync/engine/syncer_types.h"
18 #include "sync/internal_api/public/base/model_type.h"
19 #include "sync/internal_api/public/engine/sync_status.h"
20 #include "sync/engine/nudge_source.h"
22 namespace syncer {
24 class ScopedStatusLock;
25 struct ServerConnectionEvent;
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.
30 // Most of this data ends up on the about:sync page. But the page is only
31 // 'pinged' to update itself at the end of a sync cycle. A user could refresh
32 // manually, but unless their timing is excellent it's unlikely that a user will
33 // see any state in mid-sync cycle. We have no plans to change this. However,
34 // we will continue to collect data and update state mid-sync-cycle in case we
35 // need to debug slow or stuck sync cycles.
36 class AllStatus : public SyncEngineEventListener {
37 friend class ScopedStatusLock;
38 public:
39 AllStatus();
40 virtual ~AllStatus();
42 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE;
44 SyncStatus status() const;
46 void SetNotificationsEnabled(bool notifications_enabled);
48 void IncrementNotifiableCommits();
50 void IncrementNotificationsReceived();
52 void SetThrottledTypes(ModelTypeSet types);
54 void SetEncryptedTypes(ModelTypeSet types);
55 void SetCryptographerReady(bool ready);
56 void SetCryptoHasPendingKeys(bool has_pending_keys);
57 void SetPassphraseType(PassphraseType type);
58 void SetHasKeystoreKey(bool has_keystore_key);
59 void SetKeystoreMigrationTime(const base::Time& migration_time);
61 void SetSyncId(const std::string& sync_id);
62 void SetInvalidatorClientId(const std::string& invalidator_client_id);
64 void IncrementNudgeCounter(NudgeSource source);
66 protected:
67 // Examines syncer to calculate syncing and the unsynced count,
68 // and returns a Status with new values.
69 SyncStatus CalcSyncing(const SyncEngineEvent& event) const;
70 SyncStatus CreateBlankStatus() const;
72 SyncStatus status_;
74 mutable base::Lock mutex_; // Protects all data members.
75 DISALLOW_COPY_AND_ASSIGN(AllStatus);
78 class ScopedStatusLock {
79 public:
80 explicit ScopedStatusLock(AllStatus* allstatus);
81 ~ScopedStatusLock();
82 protected:
83 AllStatus* allstatus_;
86 } // namespace syncer
88 #endif // SYNC_INTERNAL_API_ALL_STATUS_H_