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

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

Issue 8189003: Send important client side event information to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: committing. Created 9 years, 2 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
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 <string> 22 #include <string>
23 23
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
25 #include "chrome/browser/sync/engine/model_safe_worker.h" 25 #include "chrome/browser/sync/engine/model_safe_worker.h"
26 #include "chrome/browser/sync/engine/syncer_types.h" 26 #include "chrome/browser/sync/engine/syncer_types.h"
27 #include "chrome/browser/sync/sessions/debug_info_getter.h"
27 28
28 namespace syncable { 29 namespace syncable {
29 class DirectoryManager; 30 class DirectoryManager;
30 } 31 }
31 32
32 namespace browser_sync { 33 namespace browser_sync {
33 34
34 class ConflictResolver; 35 class ConflictResolver;
35 class ExtensionsActivityMonitor; 36 class ExtensionsActivityMonitor;
36 class ModelSafeWorkerRegistrar; 37 class ModelSafeWorkerRegistrar;
37 class ServerConnectionManager; 38 class ServerConnectionManager;
38 39
39 // Default number of items a client can commit in a single message. 40 // Default number of items a client can commit in a single message.
40 static const int kDefaultMaxCommitBatchSize = 25; 41 static const int kDefaultMaxCommitBatchSize = 25;
41 42
42 namespace sessions { 43 namespace sessions {
43 class ScopedSessionContextConflictResolver; 44 class ScopedSessionContextConflictResolver;
44 struct SyncSessionSnapshot; 45 struct SyncSessionSnapshot;
45 class TestScopedSessionEventListener; 46 class TestScopedSessionEventListener;
46 47
47 class SyncSessionContext { 48 class SyncSessionContext {
48 public: 49 public:
49 SyncSessionContext(ServerConnectionManager* connection_manager, 50 SyncSessionContext(ServerConnectionManager* connection_manager,
50 syncable::DirectoryManager* directory_manager, 51 syncable::DirectoryManager* directory_manager,
51 ModelSafeWorkerRegistrar* model_safe_worker_registrar, 52 ModelSafeWorkerRegistrar* model_safe_worker_registrar,
52 const std::vector<SyncEngineEventListener*>& listeners); 53 const std::vector<SyncEngineEventListener*>& listeners,
54 DebugInfoGetter* debug_info_getter);
53 ~SyncSessionContext(); 55 ~SyncSessionContext();
54 56
55 ConflictResolver* resolver() { return resolver_; } 57 ConflictResolver* resolver() { return resolver_; }
56 ServerConnectionManager* connection_manager() { 58 ServerConnectionManager* connection_manager() {
57 return connection_manager_; 59 return connection_manager_;
58 } 60 }
59 syncable::DirectoryManager* directory_manager() { 61 syncable::DirectoryManager* directory_manager() {
60 return directory_manager_; 62 return directory_manager_;
61 } 63 }
62 ModelSafeWorkerRegistrar* registrar() { 64 ModelSafeWorkerRegistrar* registrar() {
63 return registrar_; 65 return registrar_;
64 } 66 }
65 ExtensionsActivityMonitor* extensions_monitor() { 67 ExtensionsActivityMonitor* extensions_monitor() {
66 return extensions_activity_monitor_; 68 return extensions_activity_monitor_;
67 } 69 }
68 70
71 DebugInfoGetter* debug_info_getter() {
72 return debug_info_getter_;
73 }
74
69 // Talk notification status. 75 // Talk notification status.
70 void set_notifications_enabled(bool enabled) { 76 void set_notifications_enabled(bool enabled) {
71 notifications_enabled_ = enabled; 77 notifications_enabled_ = enabled;
72 } 78 }
73 bool notifications_enabled() { return notifications_enabled_; } 79 bool notifications_enabled() { return notifications_enabled_; }
74 80
75 // Account name, set once a directory has been opened. 81 // Account name, set once a directory has been opened.
76 void set_account_name(const std::string name) { 82 void set_account_name(const std::string name) {
77 DCHECK(account_name_.empty()); 83 DCHECK(account_name_.empty());
78 account_name_ = name; 84 account_name_ = name;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // The server limits the number of items a client can commit in one batch. 136 // The server limits the number of items a client can commit in one batch.
131 int max_commit_batch_size_; 137 int max_commit_batch_size_;
132 138
133 // Some routing info history to help us clean up types that get disabled 139 // Some routing info history to help us clean up types that get disabled
134 // by the user. 140 // by the user.
135 ModelSafeRoutingInfo previous_session_routing_info_; 141 ModelSafeRoutingInfo previous_session_routing_info_;
136 142
137 // Cache of last session snapshot information. 143 // Cache of last session snapshot information.
138 scoped_ptr<sessions::SyncSessionSnapshot> previous_session_snapshot_; 144 scoped_ptr<sessions::SyncSessionSnapshot> previous_session_snapshot_;
139 145
146 // We use this to get debug info to send to the server for debugging
147 // client behavior on server side.
148 DebugInfoGetter* const debug_info_getter_;
149
140 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); 150 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext);
141 }; 151 };
142 152
143 // Installs a ConflictResolver to a given session context for the lifetime of 153 // Installs a ConflictResolver to a given session context for the lifetime of
144 // the ScopedSessionContextConflictResolver. There should never be more than 154 // the ScopedSessionContextConflictResolver. There should never be more than
145 // one ConflictResolver in the system, so it is an error to use this if the 155 // one ConflictResolver in the system, so it is an error to use this if the
146 // context already has a resolver. 156 // context already has a resolver.
147 class ScopedSessionContextConflictResolver { 157 class ScopedSessionContextConflictResolver {
148 public: 158 public:
149 // Note: |context| and |resolver| should outlive |this|. 159 // Note: |context| and |resolver| should outlive |this|.
150 ScopedSessionContextConflictResolver(SyncSessionContext* context, 160 ScopedSessionContextConflictResolver(SyncSessionContext* context,
151 ConflictResolver* resolver) 161 ConflictResolver* resolver)
152 : context_(context), resolver_(resolver) { 162 : context_(context), resolver_(resolver) {
153 DCHECK(NULL == context->resolver_); 163 DCHECK(NULL == context->resolver_);
154 context->resolver_ = resolver; 164 context->resolver_ = resolver;
155 } 165 }
156 ~ScopedSessionContextConflictResolver() { 166 ~ScopedSessionContextConflictResolver() {
157 context_->resolver_ = NULL; 167 context_->resolver_ = NULL;
158 } 168 }
159 private: 169 private:
160 SyncSessionContext* context_; 170 SyncSessionContext* context_;
161 ConflictResolver* resolver_; 171 ConflictResolver* resolver_;
162 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); 172 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver);
163 }; 173 };
164 174
165 } // namespace sessions 175 } // namespace sessions
166 } // namespace browser_sync 176 } // namespace browser_sync
167 177
168 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 178 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/status_controller.cc ('k') | chrome/browser/sync/sessions/sync_session_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698