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

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

Issue 6465005: [Sync] Initial support for encrypting any datatype (no UI hookup yet). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + small fix 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"
13 #include "chrome/browser/sync/engine/syncapi.h" 14 #include "chrome/browser/sync/engine/syncapi.h"
14 #include "chrome/browser/sync/glue/session_model_associator.h" 15 #include "chrome/browser/sync/glue/session_model_associator.h"
16 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/tab_contents/navigation_controller.h" 17 #include "chrome/browser/tab_contents/navigation_controller.h"
16 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
17 #include "chrome/common/notification_details.h" 19 #include "chrome/common/notification_details.h"
18 #include "chrome/common/notification_service.h" 20 #include "chrome/common/notification_service.h"
19 #include "chrome/common/notification_source.h" 21 #include "chrome/common/notification_source.h"
20 22
21 namespace browser_sync { 23 namespace browser_sync {
22 24
23 SessionChangeProcessor::SessionChangeProcessor( 25 SessionChangeProcessor::SessionChangeProcessor(
24 UnrecoverableErrorHandler* error_handler, 26 UnrecoverableErrorHandler* error_handler,
25 SessionModelAssociator* session_model_associator) 27 SessionModelAssociator* session_model_associator)
26 : ChangeProcessor(error_handler), 28 : ChangeProcessor(error_handler),
27 session_model_associator_(session_model_associator), 29 session_model_associator_(session_model_associator),
28 profile_(NULL) { 30 profile_(NULL) {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
30 DCHECK(error_handler); 32 DCHECK(error_handler);
31 DCHECK(session_model_associator_); 33 DCHECK(session_model_associator_);
32 } 34 }
33 35
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
34 SessionChangeProcessor::~SessionChangeProcessor() { 49 SessionChangeProcessor::~SessionChangeProcessor() {
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
36 } 51 }
37 52
38 void SessionChangeProcessor::Observe(NotificationType type, 53 void SessionChangeProcessor::Observe(NotificationType type,
39 const NotificationSource& source, 54 const NotificationSource& source,
40 const NotificationDetails& details) { 55 const NotificationDetails& details) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
42 DCHECK(running()); 57 DCHECK(running());
43 DCHECK(profile_); 58 DCHECK(profile_);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 "Session node lookup failed."); 191 "Session node lookup failed.");
177 return; 192 return;
178 } 193 }
179 194
180 // Check that the changed node is a child of the session folder. 195 // Check that the changed node is a child of the session folder.
181 DCHECK(root.GetId() == sync_node.GetParentId()); 196 DCHECK(root.GetId() == sync_node.GetParentId());
182 DCHECK(syncable::SESSIONS == sync_node.GetModelType()); 197 DCHECK(syncable::SESSIONS == sync_node.GetModelType());
183 198
184 const sync_pb::SessionSpecifics& specifics( 199 const sync_pb::SessionSpecifics& specifics(
185 sync_node.GetSessionSpecifics()); 200 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 }
186 const int64 mtime = sync_node.GetModificationTime(); 210 const int64 mtime = sync_node.GetModificationTime();
187 // Model associator handles foreign session update and add the same. 211 // Model associator handles foreign session update and add the same.
188 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); 212 session_model_associator_->AssociateForeignSpecifics(specifics, mtime);
189 } 213 }
190 214
191 // Notify foreign session handlers that there are new sessions. 215 // Notify foreign session handlers that there are new sessions.
192 NotificationService::current()->Notify( 216 NotificationService::current()->Notify(
193 NotificationType::FOREIGN_SESSION_UPDATED, 217 NotificationType::FOREIGN_SESSION_UPDATED,
194 NotificationService::AllSources(), 218 NotificationService::AllSources(),
195 NotificationService::NoDetails()); 219 NotificationService::NoDetails());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 NotificationService::AllSources()); 255 NotificationService::AllSources());
232 } 256 }
233 257
234 void SessionChangeProcessor::StopObserving() { 258 void SessionChangeProcessor::StopObserving() {
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
236 DCHECK(profile_); 260 DCHECK(profile_);
237 notification_registrar_.RemoveAll(); 261 notification_registrar_.RemoveAll();
238 } 262 }
239 263
240 } // namespace browser_sync 264 } // 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