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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc

Issue 59193003: [SyncFS] Add RemoteToLocalSyncer skeleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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_file_system/drive_backend/remote_to_local_syncer.h " 5 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h "
6 6
7 #include "base/bind.h"
7 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop_proxy.h"
12 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
13 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
9 14
10 namespace sync_file_system { 15 namespace sync_file_system {
11 namespace drive_backend { 16 namespace drive_backend {
12 17
13 RemoteToLocalSyncer::RemoteToLocalSyncer() { 18 namespace {
19
20 bool BuildFileSystemURLForTracker(
21 MetadataDatabase* metadata_database,
22 int tracker_id,
23 fileapi::FileSystemURL* url) {
14 NOTIMPLEMENTED(); 24 NOTIMPLEMENTED();
25 return false;
26 }
27
28 } // namespace
29
30 RemoteToLocalSyncer::RemoteToLocalSyncer(SyncEngineContext* sync_context,
31 int priorities)
32 : sync_context_(sync_context),
33 priorities_(priorities),
34 weak_ptr_factory_(this) {
15 } 35 }
16 36
17 RemoteToLocalSyncer::~RemoteToLocalSyncer() { 37 RemoteToLocalSyncer::~RemoteToLocalSyncer() {
18 NOTIMPLEMENTED(); 38 NOTIMPLEMENTED();
19 } 39 }
20 40
21 void RemoteToLocalSyncer::Run(const SyncStatusCallback& callback) { 41 void RemoteToLocalSyncer::Run(const SyncStatusCallback& callback) {
42 if (priorities_ & PRIORITY_NORMAL) {
43 if (metadata_database()->GetNormalPriorityDirtyTracker(&dirty_tracker_)) {
44 ResolveTrivial(callback);
45 return;
46 }
47 }
48
49 if (priorities_ & PRIORITY_LOW) {
50 if (metadata_database()->GetNormalPriorityDirtyTracker(&dirty_tracker_)) {
kinuko 2013/11/05 13:36:13 GetLowPriorityDirtyTracker?
tzik 2013/11/06 04:56:08 Done.
51 ResolveTrivial(callback);
52 return;
53 }
54 }
55
56 base::MessageLoopProxy::current()->PostTask(
57 FROM_HERE,
58 base::Bind(callback, SYNC_STATUS_NO_CHANGE_TO_SYNC));
59 }
60
61 void RemoteToLocalSyncer::ResolveTrivial(const SyncStatusCallback& callback) {
62 metadata_database()->ResolveTrivialDirtiness(
63 dirty_tracker_.tracker_id(),
64 base::Bind(&RemoteToLocalSyncer::DidResolveTrivial,
65 weak_ptr_factory_.GetWeakPtr(), callback));
66 }
67
68 void RemoteToLocalSyncer::DidResolveTrivial(
69 const SyncStatusCallback& callback,
70 SyncStatusCode status) {
71 if (status == SYNC_STATUS_OK) {
72 callback.Run(SYNC_STATUS_OK);
73 return;
74 }
75
76 DCHECK_EQ(SYNC_STATUS_NO_CHANGE_TO_SYNC, status);
77
78 fileapi::FileSystemURL url;
79 BuildFileSystemURLForTracker(metadata_database(),
80 dirty_tracker_.tracker_id(),
81 &url);
82 remote_change_processor()->PrepareForProcessRemoteChange(
83 url,
84 base::Bind(&RemoteToLocalSyncer::DidPrepare,
85 weak_ptr_factory_.GetWeakPtr(),
86 callback));
87 }
88
89 void RemoteToLocalSyncer::DidPrepare(const SyncStatusCallback& callback,
90 SyncStatusCode status,
91 const SyncFileMetadata& metadata,
92 const FileChangeList& changes) {
22 NOTIMPLEMENTED(); 93 NOTIMPLEMENTED();
23 callback.Run(SYNC_STATUS_FAILED); 94 callback.Run(SYNC_STATUS_FAILED);
24 } 95 }
25 96
97 drive::DriveServiceInterface* RemoteToLocalSyncer::drive_service() {
98 return sync_context_->GetDriveService();
99 }
100
101 MetadataDatabase* RemoteToLocalSyncer::metadata_database() {
102 return sync_context_->GetMetadataDatabase();
103 }
104
105 RemoteChangeProcessor* RemoteToLocalSyncer::remote_change_processor() {
106 DCHECK(sync_context_->GetRemoteChangeProcessor());
107 return sync_context_->GetRemoteChangeProcessor();
108 }
109
26 } // namespace drive_backend 110 } // namespace drive_backend
27 } // namespace sync_file_system 111 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698