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

Side by Side Diff: sync/sessions/directory_type_debug_info_emitter.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/sessions/debug_info_getter.h ('k') | sync/sessions/directory_type_debug_info_emitter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 #ifndef SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
6 #define SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/observer_list.h"
12 #include "base/values.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/internal_api/public/sessions/commit_counters.h"
15 #include "sync/internal_api/public/sessions/update_counters.h"
16 #include "sync/syncable/directory.h"
17
18 namespace syncer {
19
20 class DirectoryCommitContributor;
21 class TypeDebugInfoObserver;
22
23 // Supports various kinds of debugging requests for a certain directory type.
24 //
25 // The GetAllNodes() function is used to help export a snapshot of all current
26 // nodes to its caller. The complexity required to manage the request mostly
27 // lives elsewhere.
28 //
29 // The Emit*() functions send updates to registered TypeDebugInfoObservers.
30 // The DirectoryTypeDebugInfoEmitter does not directly own that list; it is
31 // managed by the ModelTypeRegistry.
32 //
33 // For Update and Commit counters, the job of keeping the counters up to date
34 // is delegated to the UpdateHandler and CommitContributors. For the Stats
35 // counters, the emitter will use its type_ and directory_ members to fetch all
36 // the required information on demand.
37 class SYNC_EXPORT DirectoryTypeDebugInfoEmitter {
38 public:
39 // Standard constructor for non-tests.
40 //
41 // The |directory| and |observers| arguments are not owned. Both may be
42 // modified outside of this object and both are expected to outlive this
43 // object.
44 DirectoryTypeDebugInfoEmitter(
45 syncable::Directory* directory,
46 syncer::ModelType type,
47 base::ObserverList<TypeDebugInfoObserver>* observers);
48
49 // A simple constructor for tests. Should not be used in real code.
50 DirectoryTypeDebugInfoEmitter(
51 ModelType type,
52 base::ObserverList<TypeDebugInfoObserver>* observers);
53
54 virtual ~DirectoryTypeDebugInfoEmitter();
55
56 // Returns a ListValue representation of all known nodes of this type.
57 std::unique_ptr<base::ListValue> GetAllNodes();
58
59 // Returns a reference to the current commit counters.
60 const CommitCounters& GetCommitCounters() const;
61
62 // Allows others to mutate the commit counters.
63 CommitCounters* GetMutableCommitCounters();
64
65 // Triggerss a commit counters update to registered observers.
66 void EmitCommitCountersUpdate();
67
68 // Returns a reference to the current update counters.
69 const UpdateCounters& GetUpdateCounters() const;
70
71 // Allows others to mutate the update counters.
72 UpdateCounters* GetMutableUpdateCounters();
73
74 // Triggers an update counters update to registered observers.
75 void EmitUpdateCountersUpdate();
76
77 // Triggers a status counters update to registered observers.
78 void EmitStatusCountersUpdate();
79
80 private:
81 syncable::Directory* directory_;
82
83 const ModelType type_;
84
85 CommitCounters commit_counters_;
86 UpdateCounters update_counters_;
87
88 // Because there are so many emitters that come into and out of existence, it
89 // doesn't make sense to have them manage their own observer list. They all
90 // share one observer list that is provided by their owner and which is
91 // guaranteed to outlive them.
92 base::ObserverList<TypeDebugInfoObserver>* type_debug_info_observers_;
93
94 DISALLOW_COPY_AND_ASSIGN(DirectoryTypeDebugInfoEmitter);
95 };
96
97 } // namespace syncer
98
99 #endif // SYNC_SESSIONS_DIRECTORY_TYPE_DEBUG_INFO_EMITTER_H_
OLDNEW
« no previous file with comments | « sync/sessions/debug_info_getter.h ('k') | sync/sessions/directory_type_debug_info_emitter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698