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

Side by Side Diff: chrome/browser/sync/glue/session_change_processor.cc

Issue 6537027: Revert 75287 - [Sync] Initial support for encrypting any datatype (no UI hook... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/sync/glue/session_change_processor.h" 5 #include "chrome/browser/sync/glue/session_change_processor.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/scoped_vector.h" 12 #include "base/scoped_vector.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/engine/syncapi.h" 13 #include "chrome/browser/sync/engine/syncapi.h"
15 #include "chrome/browser/sync/glue/session_model_associator.h" 14 #include "chrome/browser/sync/glue/session_model_associator.h"
16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/browser/tab_contents/navigation_controller.h" 15 #include "chrome/browser/tab_contents/navigation_controller.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 16 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/common/notification_details.h" 17 #include "chrome/common/notification_details.h"
20 #include "chrome/common/notification_service.h" 18 #include "chrome/common/notification_service.h"
21 #include "chrome/common/notification_source.h" 19 #include "chrome/common/notification_source.h"
22 20
23 namespace browser_sync { 21 namespace browser_sync {
24 22
25 SessionChangeProcessor::SessionChangeProcessor( 23 SessionChangeProcessor::SessionChangeProcessor(
26 UnrecoverableErrorHandler* error_handler, 24 UnrecoverableErrorHandler* error_handler,
27 SessionModelAssociator* session_model_associator) 25 SessionModelAssociator* session_model_associator)
28 : ChangeProcessor(error_handler), 26 : ChangeProcessor(error_handler),
29 session_model_associator_(session_model_associator), 27 session_model_associator_(session_model_associator),
30 profile_(NULL) { 28 profile_(NULL) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 DCHECK(error_handler); 30 DCHECK(error_handler);
33 DCHECK(session_model_associator_); 31 DCHECK(session_model_associator_);
34 } 32 }
35 33
36 SessionChangeProcessor::SessionChangeProcessor(
37 UnrecoverableErrorHandler* error_handler,
38 SessionModelAssociator* session_model_associator,
39 bool setup_for_test)
40 : ChangeProcessor(error_handler),
41 session_model_associator_(session_model_associator),
42 profile_(NULL),
43 setup_for_test_(setup_for_test) {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 DCHECK(error_handler);
46 DCHECK(session_model_associator_);
47 }
48
49 SessionChangeProcessor::~SessionChangeProcessor() { 34 SessionChangeProcessor::~SessionChangeProcessor() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 } 36 }
52 37
53 void SessionChangeProcessor::Observe(NotificationType type, 38 void SessionChangeProcessor::Observe(NotificationType type,
54 const NotificationSource& source, 39 const NotificationSource& source,
55 const NotificationDetails& details) { 40 const NotificationDetails& details) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 DCHECK(running()); 42 DCHECK(running());
58 DCHECK(profile_); 43 DCHECK(profile_);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 "Session node lookup failed."); 176 "Session node lookup failed.");
192 return; 177 return;
193 } 178 }
194 179
195 // Check that the changed node is a child of the session folder. 180 // Check that the changed node is a child of the session folder.
196 DCHECK(root.GetId() == sync_node.GetParentId()); 181 DCHECK(root.GetId() == sync_node.GetParentId());
197 DCHECK(syncable::SESSIONS == sync_node.GetModelType()); 182 DCHECK(syncable::SESSIONS == sync_node.GetModelType());
198 183
199 const sync_pb::SessionSpecifics& specifics( 184 const sync_pb::SessionSpecifics& specifics(
200 sync_node.GetSessionSpecifics()); 185 sync_node.GetSessionSpecifics());
201 if (specifics.session_tag() ==
202 session_model_associator_->GetCurrentMachineTag() &&
203 !setup_for_test_) {
204 // We should only ever receive a change to our own machine's session info
205 // if encryption was turned on. In that case, the data is still the same,
206 // so we can ignore.
207 LOG(WARNING) << "Dropping modification to local session.";
208 return;
209 }
210 const int64 mtime = sync_node.GetModificationTime(); 186 const int64 mtime = sync_node.GetModificationTime();
211 // Model associator handles foreign session update and add the same. 187 // Model associator handles foreign session update and add the same.
212 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); 188 session_model_associator_->AssociateForeignSpecifics(specifics, mtime);
213 } 189 }
214 190
215 // Notify foreign session handlers that there are new sessions. 191 // Notify foreign session handlers that there are new sessions.
216 NotificationService::current()->Notify( 192 NotificationService::current()->Notify(
217 NotificationType::FOREIGN_SESSION_UPDATED, 193 NotificationType::FOREIGN_SESSION_UPDATED,
218 NotificationService::AllSources(), 194 NotificationService::AllSources(),
219 NotificationService::NoDetails()); 195 NotificationService::NoDetails());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 NotificationService::AllSources()); 231 NotificationService::AllSources());
256 } 232 }
257 233
258 void SessionChangeProcessor::StopObserving() { 234 void SessionChangeProcessor::StopObserving() {
259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
260 DCHECK(profile_); 236 DCHECK(profile_);
261 notification_registrar_.RemoveAll(); 237 notification_registrar_.RemoveAll();
262 } 238 }
263 239
264 } // namespace browser_sync 240 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_change_processor.h ('k') | chrome/browser/sync/glue/session_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698