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

Side by Side Diff: chrome/browser/sync/sessions2/sessions_sync_manager.cc

Issue 217063005: Separate SyncData methods into three groups, local, remote, and common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Rebase. Created 6 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sessions2/sessions_sync_manager.h" 5 #include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #if !defined(OS_ANDROID) 8 #if !defined(OS_ANDROID)
9 #include "chrome/browser/network_time/navigation_time_helper.h" 9 #include "chrome/browser/network_time/navigation_time_helper.h"
10 #endif 10 #endif
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 case syncer::SyncChange::ACTION_ADD: 481 case syncer::SyncChange::ACTION_ADD:
482 case syncer::SyncChange::ACTION_UPDATE: 482 case syncer::SyncChange::ACTION_UPDATE:
483 if (current_machine_tag() == session.session_tag()) { 483 if (current_machine_tag() == session.session_tag()) {
484 // We should only ever receive a change to our own machine's session 484 // We should only ever receive a change to our own machine's session
485 // info if encryption was turned on. In that case, the data is still 485 // info if encryption was turned on. In that case, the data is still
486 // the same, so we can ignore. 486 // the same, so we can ignore.
487 LOG(WARNING) << "Dropping modification to local session."; 487 LOG(WARNING) << "Dropping modification to local session.";
488 return syncer::SyncError(); 488 return syncer::SyncError();
489 } 489 }
490 UpdateTrackerWithForeignSession( 490 UpdateTrackerWithForeignSession(
491 session, it->sync_data().GetRemoteModifiedTime()); 491 session, syncer::SyncDataRemote(it->sync_data()).GetModifiedTime());
492 break; 492 break;
493 default: 493 default:
494 NOTREACHED() << "Processing sync changes failed, unknown change type."; 494 NOTREACHED() << "Processing sync changes failed, unknown change type.";
495 } 495 }
496 } 496 }
497 497
498 content::NotificationService::current()->Notify( 498 content::NotificationService::current()->Notify(
499 chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, 499 chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
500 content::Source<Profile>(profile_), 500 content::Source<Profile>(profile_),
501 content::NotificationService::NoDetails()); 501 content::NotificationService::NoDetails());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 const syncer::SyncData& data = *it; 534 const syncer::SyncData& data = *it;
535 DCHECK(data.GetSpecifics().has_session()); 535 DCHECK(data.GetSpecifics().has_session());
536 const sync_pb::SessionSpecifics& specifics = data.GetSpecifics().session(); 536 const sync_pb::SessionSpecifics& specifics = data.GetSpecifics().session();
537 if (specifics.session_tag().empty() || 537 if (specifics.session_tag().empty() ||
538 (specifics.has_tab() && (!specifics.has_tab_node_id() || 538 (specifics.has_tab() && (!specifics.has_tab_node_id() ||
539 !specifics.tab().has_tab_id()))) { 539 !specifics.tab().has_tab_id()))) {
540 syncer::SyncChange tombstone(TombstoneTab(specifics)); 540 syncer::SyncChange tombstone(TombstoneTab(specifics));
541 if (tombstone.IsValid()) 541 if (tombstone.IsValid())
542 new_changes->push_back(tombstone); 542 new_changes->push_back(tombstone);
543 } else if (specifics.session_tag() != current_machine_tag()) { 543 } else if (specifics.session_tag() != current_machine_tag()) {
544 UpdateTrackerWithForeignSession(specifics, data.GetRemoteModifiedTime()); 544 UpdateTrackerWithForeignSession(
545 specifics, syncer::SyncDataRemote(data).GetModifiedTime());
545 } else { 546 } else {
546 // This is previously stored local session information. 547 // This is previously stored local session information.
547 if (specifics.has_header() && !found_current_header) { 548 if (specifics.has_header() && !found_current_header) {
548 // This is our previous header node, reuse it. 549 // This is our previous header node, reuse it.
549 found_current_header = true; 550 found_current_header = true;
550 if (specifics.header().has_client_name()) 551 if (specifics.header().has_client_name())
551 current_session_name_ = specifics.header().client_name(); 552 current_session_name_ = specifics.header().client_name();
552 } else { 553 } else {
553 if (specifics.has_header() || !specifics.has_tab()) { 554 if (specifics.has_header() || !specifics.has_tab()) {
554 LOG(WARNING) << "Found more than one session header node with local " 555 LOG(WARNING) << "Found more than one session header node with local "
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 << " with age " << session_age_in_days << ", deleting."; 995 << " with age " << session_age_in_days << ", deleting.";
995 DeleteForeignSessionInternal(session_tag, &changes); 996 DeleteForeignSessionInternal(session_tag, &changes);
996 } 997 }
997 } 998 }
998 999
999 if (!changes.empty()) 1000 if (!changes.empty())
1000 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 1001 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
1001 } 1002 }
1002 1003
1003 }; // namespace browser_sync 1004 }; // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698