| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/fake_remote_change_processor.h" | 5 #include "chrome/browser/sync_file_system/fake_remote_change_processor.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "webkit/fileapi/file_system_url.h" | 11 #include "webkit/fileapi/file_system_url.h" |
| 12 #include "webkit/fileapi/syncable/file_change.h" | 12 #include "webkit/fileapi/syncable/file_change.h" |
| 13 #include "webkit/fileapi/syncable/sync_file_metadata.h" | 13 #include "webkit/fileapi/syncable/sync_file_metadata.h" |
| 14 | 14 |
| 15 namespace sync_file_system { | 15 namespace sync_file_system { |
| 16 | 16 |
| 17 FakeRemoteChangeProcessor::FakeRemoteChangeProcessor() { | 17 FakeRemoteChangeProcessor::FakeRemoteChangeProcessor() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 FakeRemoteChangeProcessor::~FakeRemoteChangeProcessor() { | 20 FakeRemoteChangeProcessor::~FakeRemoteChangeProcessor() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void FakeRemoteChangeProcessor::PrepareForProcessRemoteChange( | 23 void FakeRemoteChangeProcessor::PrepareForProcessRemoteChange( |
| 24 const fileapi::FileSystemURL& url, | 24 const fileapi::FileSystemURL& url, |
| 25 const std::string& service_name, | 25 const std::string& service_name, |
| 26 const PrepareChangeCallback& callback) { | 26 const PrepareChangeCallback& callback) { |
| 27 SyncFileMetadata local_metadata; |
| 28 |
| 29 URLToFileChangesMap::iterator found = applied_changes_.find(url); |
| 30 if (found != applied_changes_.end()) { |
| 31 DCHECK(!found->second.empty()); |
| 32 const FileChange& applied_change = found->second.back(); |
| 33 if (applied_change.IsAddOrUpdate()) { |
| 34 local_metadata = SyncFileMetadata( |
| 35 applied_change.file_type(), |
| 36 100 /* size */, |
| 37 base::Time::Now()); |
| 38 } |
| 39 } |
| 27 base::MessageLoopProxy::current()->PostTask( | 40 base::MessageLoopProxy::current()->PostTask( |
| 28 FROM_HERE, | 41 FROM_HERE, |
| 29 base::Bind(callback, SYNC_STATUS_OK, | 42 base::Bind(callback, SYNC_STATUS_OK, |
| 30 SyncFileMetadata(), FileChangeList())); | 43 local_metadata, FileChangeList())); |
| 31 } | 44 } |
| 32 | 45 |
| 33 void FakeRemoteChangeProcessor::ApplyRemoteChange( | 46 void FakeRemoteChangeProcessor::ApplyRemoteChange( |
| 34 const FileChange& change, | 47 const FileChange& change, |
| 35 const base::FilePath& local_path, | 48 const base::FilePath& local_path, |
| 36 const fileapi::FileSystemURL& url, | 49 const fileapi::FileSystemURL& url, |
| 37 const SyncStatusCallback& callback) { | 50 const SyncStatusCallback& callback) { |
| 38 applied_changes_[url].push_back(change); | 51 applied_changes_[url].push_back(change); |
| 39 base::MessageLoopProxy::current()->PostTask( | 52 base::MessageLoopProxy::current()->PostTask( |
| 40 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); | 53 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 53 base::MessageLoopProxy::current()->PostTask( | 66 base::MessageLoopProxy::current()->PostTask( |
| 54 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); | 67 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); |
| 55 } | 68 } |
| 56 | 69 |
| 57 const FakeRemoteChangeProcessor::URLToFileChangesMap& | 70 const FakeRemoteChangeProcessor::URLToFileChangesMap& |
| 58 FakeRemoteChangeProcessor::GetAppliedRemoteChanges() const { | 71 FakeRemoteChangeProcessor::GetAppliedRemoteChanges() const { |
| 59 return applied_changes_; | 72 return applied_changes_; |
| 60 } | 73 } |
| 61 | 74 |
| 62 } // namespace sync_file_system | 75 } // namespace sync_file_system |
| OLD | NEW |