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

Side by Side Diff: sync/engine/directory_update_handler.cc

Issue 215973007: [Sync] Add plumbing of context from client to server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sync/engine/directory_update_handler.h" 5 #include "sync/engine/directory_update_handler.h"
6 6
7 #include "sync/engine/conflict_resolver.h" 7 #include "sync/engine/conflict_resolver.h"
8 #include "sync/engine/process_updates_util.h" 8 #include "sync/engine/process_updates_util.h"
9 #include "sync/engine/update_applicator.h" 9 #include "sync/engine/update_applicator.h"
10 #include "sync/sessions/status_controller.h" 10 #include "sync/sessions/status_controller.h"
(...skipping 13 matching lines...) Expand all
24 type_(type), 24 type_(type),
25 worker_(worker) {} 25 worker_(worker) {}
26 26
27 DirectoryUpdateHandler::~DirectoryUpdateHandler() {} 27 DirectoryUpdateHandler::~DirectoryUpdateHandler() {}
28 28
29 void DirectoryUpdateHandler::GetDownloadProgress( 29 void DirectoryUpdateHandler::GetDownloadProgress(
30 sync_pb::DataTypeProgressMarker* progress_marker) const { 30 sync_pb::DataTypeProgressMarker* progress_marker) const {
31 dir_->GetDownloadProgress(type_, progress_marker); 31 dir_->GetDownloadProgress(type_, progress_marker);
32 } 32 }
33 33
34 void DirectoryUpdateHandler::GetDataTypeContext(
35 sync_pb::DataTypeContext* context) const {
36 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
37 dir_->GetDataTypeContext(&trans, type_, context);
38 }
39
34 void DirectoryUpdateHandler::ProcessGetUpdatesResponse( 40 void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
35 const sync_pb::DataTypeProgressMarker& progress_marker, 41 const sync_pb::DataTypeProgressMarker& progress_marker,
42 const sync_pb::DataTypeContext& mutated_context,
36 const SyncEntityList& applicable_updates, 43 const SyncEntityList& applicable_updates,
37 sessions::StatusController* status) { 44 sessions::StatusController* status) {
38 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 45 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
39 UpdateSyncEntities(&trans, applicable_updates, status); 46 UpdateSyncEntities(&trans, applicable_updates, status);
40 47
41 if (IsValidProgressMarker(progress_marker)) { 48 if (IsValidProgressMarker(progress_marker)) {
42 ExpireEntriesIfNeeded(&trans, progress_marker); 49 ExpireEntriesIfNeeded(&trans, progress_marker);
43 UpdateProgressMarker(progress_marker); 50 UpdateProgressMarker(progress_marker);
44 } 51 }
52
53 if (mutated_context.has_context()) {
54 sync_pb::DataTypeContext local_context;
55 dir_->GetDataTypeContext(&trans, type_, &local_context);
56
57 // Only update the local context if it is still relevant. If the local
58 // version is higher, it means a local change happened while the mutation
59 // was in flight, and the local context takes priority.
60 if (mutated_context.version() >= local_context.version() &&
61 local_context.context() != mutated_context.context()) {
62 dir_->SetDataTypeContext(&trans, type_, mutated_context);
63 // TODO(zea): trigger the datatype's UpdateDataTypeContext method.
64 }
65 }
45 } 66 }
46 67
47 void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) { 68 void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
48 if (!IsApplyUpdatesRequired()) { 69 if (!IsApplyUpdatesRequired()) {
49 return; 70 return;
50 } 71 }
51 72
52 // This will invoke handlers that belong to the model and its thread, so we 73 // This will invoke handlers that belong to the model and its thread, so we
53 // switch to the appropriate thread before we start this work. 74 // switch to the appropriate thread before we start this work.
54 WorkCallback c = base::Bind( 75 WorkCallback c = base::Bind(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 new_gc_directive.version_watermark())) { 221 new_gc_directive.version_watermark())) {
201 ExpireEntriesByVersion(dir_, trans, type_, 222 ExpireEntriesByVersion(dir_, trans, type_,
202 new_gc_directive.version_watermark()); 223 new_gc_directive.version_watermark());
203 } 224 }
204 225
205 cached_gc_directive_.reset( 226 cached_gc_directive_.reset(
206 new sync_pb::GarbageCollectionDirective(new_gc_directive)); 227 new sync_pb::GarbageCollectionDirective(new_gc_directive));
207 } 228 }
208 229
209 } // namespace syncer 230 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/directory_update_handler.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698