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

Side by Side Diff: chrome/browser/sync_file_system/fake_remote_change_processor.cc

Issue 363373003: Replace MessageLoopProxy::current() with ThreadTaskRunnerHandle::Get() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 (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/message_loop_proxy.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/sync_file_system/file_change.h" 12 #include "chrome/browser/sync_file_system/file_change.h"
12 #include "chrome/browser/sync_file_system/sync_file_metadata.h" 13 #include "chrome/browser/sync_file_system/sync_file_metadata.h"
13 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 14 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/browser/fileapi/file_system_url.h" 16 #include "webkit/browser/fileapi/file_system_url.h"
16 #include "webkit/common/fileapi/file_system_util.h" 17 #include "webkit/common/fileapi/file_system_util.h"
17 18
18 namespace sync_file_system { 19 namespace sync_file_system {
19 20
20 FakeRemoteChangeProcessor::FakeRemoteChangeProcessor() { 21 FakeRemoteChangeProcessor::FakeRemoteChangeProcessor() {
(...skipping 28 matching lines...) Expand all
49 100 /* size */, 50 100 /* size */,
50 base::Time::Now()); 51 base::Time::Now());
51 } 52 }
52 } 53 }
53 54
54 FileChangeList change_list; 55 FileChangeList change_list;
55 URLToFileChangeList::iterator found_list = local_changes_.find(url); 56 URLToFileChangeList::iterator found_list = local_changes_.find(url);
56 if (found_list != local_changes_.end()) 57 if (found_list != local_changes_.end())
57 change_list = found_list->second; 58 change_list = found_list->second;
58 59
59 base::MessageLoopProxy::current()->PostTask( 60 base::ThreadTaskRunnerHandle::Get()->PostTask(
60 FROM_HERE, 61 FROM_HERE,
61 base::Bind(callback, SYNC_STATUS_OK, 62 base::Bind(callback, SYNC_STATUS_OK,
62 local_metadata, change_list)); 63 local_metadata, change_list));
63 } 64 }
64 65
65 void FakeRemoteChangeProcessor::ApplyRemoteChange( 66 void FakeRemoteChangeProcessor::ApplyRemoteChange(
66 const FileChange& change, 67 const FileChange& change,
67 const base::FilePath& local_path, 68 const base::FilePath& local_path,
68 const fileapi::FileSystemURL& url, 69 const fileapi::FileSystemURL& url,
69 const SyncStatusCallback& callback) { 70 const SyncStatusCallback& callback) {
(...skipping 18 matching lines...) Expand all
88 89
89 base::FilePath ancestor_parent = fileapi::VirtualPath::DirName(ancestor); 90 base::FilePath ancestor_parent = fileapi::VirtualPath::DirName(ancestor);
90 if (ancestor == ancestor_parent) 91 if (ancestor == ancestor_parent)
91 break; 92 break;
92 ancestor = ancestor_parent; 93 ancestor = ancestor_parent;
93 } 94 }
94 if (status == SYNC_STATUS_UNKNOWN) { 95 if (status == SYNC_STATUS_UNKNOWN) {
95 applied_changes_[url].push_back(change); 96 applied_changes_[url].push_back(change);
96 status = SYNC_STATUS_OK; 97 status = SYNC_STATUS_OK;
97 } 98 }
98 base::MessageLoopProxy::current()->PostTask( 99 base::ThreadTaskRunnerHandle::Get()->PostTask(
99 FROM_HERE, base::Bind(callback, status)); 100 FROM_HERE, base::Bind(callback, status));
100 } 101 }
101 102
102 void FakeRemoteChangeProcessor::FinalizeRemoteSync( 103 void FakeRemoteChangeProcessor::FinalizeRemoteSync(
103 const fileapi::FileSystemURL& url, 104 const fileapi::FileSystemURL& url,
104 bool clear_local_changes, 105 bool clear_local_changes,
105 const base::Closure& completion_callback) { 106 const base::Closure& completion_callback) {
106 base::MessageLoopProxy::current()->PostTask(FROM_HERE, completion_callback); 107 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, completion_callback);
107 } 108 }
108 109
109 void FakeRemoteChangeProcessor::RecordFakeLocalChange( 110 void FakeRemoteChangeProcessor::RecordFakeLocalChange(
110 const fileapi::FileSystemURL& url, 111 const fileapi::FileSystemURL& url,
111 const FileChange& change, 112 const FileChange& change,
112 const SyncStatusCallback& callback) { 113 const SyncStatusCallback& callback) {
113 local_changes_[url].Update(change); 114 local_changes_[url].Update(change);
114 base::MessageLoopProxy::current()->PostTask( 115 base::ThreadTaskRunnerHandle::Get()->PostTask(
115 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); 116 FROM_HERE, base::Bind(callback, SYNC_STATUS_OK));
116 } 117 }
117 118
118 void FakeRemoteChangeProcessor::UpdateLocalFileMetadata( 119 void FakeRemoteChangeProcessor::UpdateLocalFileMetadata(
119 const fileapi::FileSystemURL& url, 120 const fileapi::FileSystemURL& url,
120 const FileChange& change) { 121 const FileChange& change) {
121 if (change.IsAddOrUpdate()) { 122 if (change.IsAddOrUpdate()) {
122 local_file_metadata_[url] = SyncFileMetadata( 123 local_file_metadata_[url] = SyncFileMetadata(
123 change.file_type(), 100 /* size */, base::Time::Now()); 124 change.file_type(), 100 /* size */, base::Time::Now());
124 } else { 125 } else {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 for (size_t i = 0; i < applied.size() && i < expected.size(); ++i) { 165 for (size_t i = 0; i < applied.size() && i < expected.size(); ++i) {
165 EXPECT_EQ(expected[i], applied[i]) 166 EXPECT_EQ(expected[i], applied[i])
166 << url.DebugString() 167 << url.DebugString()
167 << " expected:" << expected[i].DebugString() 168 << " expected:" << expected[i].DebugString()
168 << " applied:" << applied[i].DebugString(); 169 << " applied:" << applied[i].DebugString();
169 } 170 }
170 } 171 }
171 } 172 }
172 173
173 } // namespace sync_file_system 174 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698