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

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: 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 dir_->GetDataTypeContext(type_, context);
37 }
38
34 void DirectoryUpdateHandler::ProcessGetUpdatesResponse( 39 void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
35 const sync_pb::DataTypeProgressMarker& progress_marker, 40 const sync_pb::DataTypeProgressMarker& progress_marker,
36 const SyncEntityList& applicable_updates, 41 const SyncEntityList& applicable_updates,
37 sessions::StatusController* status) { 42 sessions::StatusController* status) {
38 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); 43 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
39 UpdateSyncEntities(&trans, applicable_updates, status); 44 UpdateSyncEntities(&trans, applicable_updates, status);
40 45
41 if (IsValidProgressMarker(progress_marker)) { 46 if (IsValidProgressMarker(progress_marker)) {
42 ExpireEntriesIfNeeded(&trans, progress_marker); 47 ExpireEntriesIfNeeded(&trans, progress_marker);
43 UpdateProgressMarker(progress_marker); 48 UpdateProgressMarker(progress_marker);
44 } 49 }
45 } 50 }
46 51
52 void DirectoryUpdateHandler::ProcessDataTypeContextMutation(
rlarocque 2014/04/03 17:31:58 Does the context need to be updated atomically wit
Nicolas Zea 2014/04/03 22:56:47 Done.
53 const sync_pb::DataTypeContext& mutated_context) {
54 sync_pb::DataTypeContext local_context;
55 dir_->GetDataTypeContext(type_, &local_context);
56
57 // Only update the local context if it is still relevant. If the local version
58 // is higher, it means a local change happened while the mutation was in
59 // flight, and the local context takes priority.
60 if (mutated_context.version() >= local_context.version()) {
61 dir_->SetDataTypeContext(type_, mutated_context);
62 // TODO(zea): trigger the datatype's UpdateDataTypeContext method.
63 }
64 }
65
47 void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) { 66 void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
48 if (!IsApplyUpdatesRequired()) { 67 if (!IsApplyUpdatesRequired()) {
49 return; 68 return;
50 } 69 }
51 70
52 // This will invoke handlers that belong to the model and its thread, so we 71 // 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. 72 // switch to the appropriate thread before we start this work.
54 WorkCallback c = base::Bind( 73 WorkCallback c = base::Bind(
55 &DirectoryUpdateHandler::ApplyUpdatesImpl, 74 &DirectoryUpdateHandler::ApplyUpdatesImpl,
56 // We wait until the callback is executed. We can safely use Unretained. 75 // We wait until the callback is executed. We can safely use Unretained.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 new_gc_directive.version_watermark())) { 219 new_gc_directive.version_watermark())) {
201 ExpireEntriesByVersion(dir_, trans, type_, 220 ExpireEntriesByVersion(dir_, trans, type_,
202 new_gc_directive.version_watermark()); 221 new_gc_directive.version_watermark());
203 } 222 }
204 223
205 cached_gc_directive_.reset( 224 cached_gc_directive_.reset(
206 new sync_pb::GarbageCollectionDirective(new_gc_directive)); 225 new sync_pb::GarbageCollectionDirective(new_gc_directive));
207 } 226 }
208 227
209 } // namespace syncer 228 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698