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

Side by Side Diff: chrome/browser/sync/sessions/sync_session_context.h

Issue 8631021: [Sync] Prevent uploading throttled datatypes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // SyncSessionContext encapsulates the contextual information and engine 5 // SyncSessionContext encapsulates the contextual information and engine
6 // components specific to a SyncSession. A context is accessible via 6 // components specific to a SyncSession. A context is accessible via
7 // a SyncSession so that session SyncerCommands and parts of the engine have 7 // a SyncSession so that session SyncerCommands and parts of the engine have
8 // a convenient way to access other parts. In this way it can be thought of as 8 // a convenient way to access other parts. In this way it can be thought of as
9 // the surrounding environment for the SyncSession. The components of this 9 // the surrounding environment for the SyncSession. The components of this
10 // environment are either valid or not valid for the entire context lifetime, 10 // environment are either valid or not valid for the entire context lifetime,
11 // or they are valid for explicitly scoped periods of time by using Scoped 11 // or they are valid for explicitly scoped periods of time by using Scoped
12 // installation utilities found below. This means that the context assumes no 12 // installation utilities found below. This means that the context assumes no
13 // ownership whatsoever of any object that was not created by the context 13 // ownership whatsoever of any object that was not created by the context
14 // itself. 14 // itself.
15 // 15 //
16 // It can only be used from the SyncerThread. 16 // It can only be used from the SyncerThread.
17 17
18 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 18 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
19 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 19 #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
20 #pragma once 20 #pragma once
21 21
22 #include <map> 22 #include <map>
23 #include <string> 23 #include <string>
24 24
25 #include "base/gtest_prod_util.h"
25 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
26 #include "base/time.h" 27 #include "base/time.h"
27 #include "chrome/browser/sync/engine/model_safe_worker.h" 28 #include "chrome/browser/sync/engine/model_safe_worker.h"
28 #include "chrome/browser/sync/engine/syncer_types.h" 29 #include "chrome/browser/sync/engine/syncer_types.h"
29 #include "chrome/browser/sync/sessions/debug_info_getter.h" 30 #include "chrome/browser/sync/sessions/debug_info_getter.h"
30 31
31 namespace syncable { 32 namespace syncable {
32 class DirectoryManager; 33 class DirectoryManager;
33 } 34 }
34 35
35 namespace browser_sync { 36 namespace browser_sync {
36 37
37 class ConflictResolver; 38 class ConflictResolver;
38 class ExtensionsActivityMonitor; 39 class ExtensionsActivityMonitor;
39 class ModelSafeWorkerRegistrar; 40 class ModelSafeWorkerRegistrar;
40 class ServerConnectionManager; 41 class ServerConnectionManager;
41 42
42 // Default number of items a client can commit in a single message. 43 // Default number of items a client can commit in a single message.
43 static const int kDefaultMaxCommitBatchSize = 25; 44 static const int kDefaultMaxCommitBatchSize = 25;
44 45
45 namespace sessions { 46 namespace sessions {
46 class ScopedSessionContextConflictResolver; 47 class ScopedSessionContextConflictResolver;
48 class SyncSessionContextTest;
47 struct SyncSessionSnapshot; 49 struct SyncSessionSnapshot;
48 class TestScopedSessionEventListener; 50 class TestScopedSessionEventListener;
49 51
50 class SyncSessionContext { 52 class SyncSessionContext {
51 public: 53 public:
52 SyncSessionContext(ServerConnectionManager* connection_manager, 54 SyncSessionContext(ServerConnectionManager* connection_manager,
53 syncable::DirectoryManager* directory_manager, 55 syncable::DirectoryManager* directory_manager,
54 ModelSafeWorkerRegistrar* model_safe_worker_registrar, 56 ModelSafeWorkerRegistrar* model_safe_worker_registrar,
55 const std::vector<SyncEngineEventListener*>& listeners, 57 const std::vector<SyncEngineEventListener*>& listeners,
56 DebugInfoGetter* debug_info_getter); 58 DebugInfoGetter* debug_info_getter);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { 104 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) {
103 previous_session_routing_info_ = info; 105 previous_session_routing_info_ = info;
104 } 106 }
105 107
106 void NotifyListeners(const SyncEngineEvent& event) { 108 void NotifyListeners(const SyncEngineEvent& event) {
107 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, 109 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_,
108 OnSyncEngineEvent(event)); 110 OnSyncEngineEvent(event));
109 } 111 }
110 112
111 // This is virtual for unit tests. 113 // This is virtual for unit tests.
112 // TODO(lipalani) Consult the unthrottle times before committing data to
113 // the server.
114 virtual void SetUnthrottleTime(const syncable::ModelTypeSet& types, 114 virtual void SetUnthrottleTime(const syncable::ModelTypeSet& types,
115 const base::TimeTicks& time); 115 const base::TimeTicks& time);
116 116
117 // This is virtual for unit tests.
118 virtual syncable::ModelTypeSet UpdateAndGetCurrentlyThrottledTypes();
akalin 2011/11/22 23:34:17 I feel like it's kind of awkward to expose the fac
lipalani1 2011/11/23 01:33:51 I have done this little differently. Let me know w
119
117 private: 120 private:
118 typedef std::map<syncable::ModelType, base::TimeTicks> UnthrottleTimes; 121 typedef std::map<syncable::ModelType, base::TimeTicks> UnthrottleTimes;
119 122
123 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest, AddUnthrottleTimeTest);
124 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest,
125 GetCurrentlyThrottledTypesTest);
126
127 void UpdateThrottledTypes(const base::TimeTicks& time);
128 syncable::ModelTypeSet GetThrottledTypes() const;
129
120 // Rather than force clients to set and null-out various context members, we 130 // Rather than force clients to set and null-out various context members, we
121 // extend our encapsulation boundary to scoped helpers that take care of this 131 // extend our encapsulation boundary to scoped helpers that take care of this
122 // once they are allocated. See definitions of these below. 132 // once they are allocated. See definitions of these below.
123 friend class ScopedSessionContextConflictResolver; 133 friend class ScopedSessionContextConflictResolver;
124 friend class TestScopedSessionEventListener; 134 friend class TestScopedSessionEventListener;
125 135
126 // This is installed by Syncer objects when needed and may be NULL. 136 // This is installed by Syncer objects when needed and may be NULL.
127 ConflictResolver* resolver_; 137 ConflictResolver* resolver_;
128 138
129 ObserverList<SyncEngineEventListener> listeners_; 139 ObserverList<SyncEngineEventListener> listeners_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 private: 196 private:
187 SyncSessionContext* context_; 197 SyncSessionContext* context_;
188 ConflictResolver* resolver_; 198 ConflictResolver* resolver_;
189 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); 199 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver);
190 }; 200 };
191 201
192 } // namespace sessions 202 } // namespace sessions
193 } // namespace browser_sync 203 } // namespace browser_sync
194 204
195 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 205 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698