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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend_v1/fake_api_util.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 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_v1/fake_api_util.h" 5 #include "chrome/browser/sync_file_system/drive_backend_v1/fake_api_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h"
12 #include "google_apis/drive/drive_entry_kinds.h" 13 #include "google_apis/drive/drive_entry_kinds.h"
13 #include "webkit/common/blob/scoped_file.h" 14 #include "webkit/common/blob/scoped_file.h"
14 15
15 namespace sync_file_system { 16 namespace sync_file_system {
16 namespace drive_backend { 17 namespace drive_backend {
17 18
18 bool FakeAPIUtil::RemoteResourceComparator::operator()( 19 bool FakeAPIUtil::RemoteResourceComparator::operator()(
19 const RemoteResource& left, 20 const RemoteResource& left,
20 const RemoteResource& right) { 21 const RemoteResource& right) {
21 if (left.parent_resource_id != right.parent_resource_id) 22 if (left.parent_resource_id != right.parent_resource_id)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction)) {} 70 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction)) {}
70 71
71 FakeAPIUtil::~FakeAPIUtil() {} 72 FakeAPIUtil::~FakeAPIUtil() {}
72 73
73 void FakeAPIUtil::AddObserver(APIUtilObserver* observer) {} 74 void FakeAPIUtil::AddObserver(APIUtilObserver* observer) {}
74 75
75 void FakeAPIUtil::RemoveObserver(APIUtilObserver* observer) {} 76 void FakeAPIUtil::RemoveObserver(APIUtilObserver* observer) {}
76 77
77 void FakeAPIUtil::GetDriveDirectoryForSyncRoot( 78 void FakeAPIUtil::GetDriveDirectoryForSyncRoot(
78 const ResourceIdCallback& callback) { 79 const ResourceIdCallback& callback) {
79 base::MessageLoopProxy::current()->PostTask( 80 base::ThreadTaskRunnerHandle::Get()->PostTask(
80 FROM_HERE, 81 FROM_HERE,
81 base::Bind(callback, 82 base::Bind(callback,
82 google_apis::HTTP_SUCCESS, 83 google_apis::HTTP_SUCCESS,
83 "folder: sync_root_resource_id")); 84 "folder: sync_root_resource_id"));
84 } 85 }
85 86
86 void FakeAPIUtil::GetDriveDirectoryForOrigin( 87 void FakeAPIUtil::GetDriveDirectoryForOrigin(
87 const std::string& sync_root_resource_id, 88 const std::string& sync_root_resource_id,
88 const GURL& origin, 89 const GURL& origin,
89 const ResourceIdCallback& callback) { 90 const ResourceIdCallback& callback) {
90 base::MessageLoopProxy::current()->PostTask( 91 base::ThreadTaskRunnerHandle::Get()->PostTask(
91 FROM_HERE, 92 FROM_HERE,
92 base::Bind(callback, 93 base::Bind(callback,
93 google_apis::HTTP_SUCCESS, 94 google_apis::HTTP_SUCCESS,
94 "folder resource_id for " + origin.host())); 95 "folder resource_id for " + origin.host()));
95 } 96 }
96 97
97 void FakeAPIUtil::GetLargestChangeStamp(const ChangeStampCallback& callback) { 98 void FakeAPIUtil::GetLargestChangeStamp(const ChangeStampCallback& callback) {
98 base::MessageLoopProxy::current()->PostTask( 99 base::ThreadTaskRunnerHandle::Get()->PostTask(
99 FROM_HERE, 100 FROM_HERE,
100 base::Bind(callback, google_apis::HTTP_SUCCESS, largest_changestamp_)); 101 base::Bind(callback, google_apis::HTTP_SUCCESS, largest_changestamp_));
101 } 102 }
102 103
103 void FakeAPIUtil::GetResourceEntry(const std::string& resource_id, 104 void FakeAPIUtil::GetResourceEntry(const std::string& resource_id,
104 const ResourceEntryCallback& callback) { 105 const ResourceEntryCallback& callback) {
105 NOTREACHED(); 106 NOTREACHED();
106 } 107 }
107 108
108 void FakeAPIUtil::ListFiles(const std::string& directory_resource_id, 109 void FakeAPIUtil::ListFiles(const std::string& directory_resource_id,
(...skipping 15 matching lines...) Expand all
124 scoped_ptr<google_apis::ResourceEntry> entry( 125 scoped_ptr<google_apis::ResourceEntry> entry(
125 CreateResourceEntry(itr->second)); 126 CreateResourceEntry(itr->second));
126 entries.push_back(entry.release()); 127 entries.push_back(entry.release());
127 } 128 }
128 129
129 std::sort(entries.begin(), entries.end(), ChangeStampComparator()); 130 std::sort(entries.begin(), entries.end(), ChangeStampComparator());
130 131
131 change_feed->set_entries(entries.Pass()); 132 change_feed->set_entries(entries.Pass());
132 change_feed->set_largest_changestamp(largest_changestamp_); 133 change_feed->set_largest_changestamp(largest_changestamp_);
133 134
134 base::MessageLoopProxy::current()->PostTask( 135 base::ThreadTaskRunnerHandle::Get()->PostTask(
135 FROM_HERE, 136 FROM_HERE,
136 base::Bind( 137 base::Bind(
137 callback, google_apis::HTTP_SUCCESS, base::Passed(&change_feed))); 138 callback, google_apis::HTTP_SUCCESS, base::Passed(&change_feed)));
138 } 139 }
139 140
140 void FakeAPIUtil::ContinueListing(const GURL& next_link, 141 void FakeAPIUtil::ContinueListing(const GURL& next_link,
141 const ResourceListCallback& callback) { 142 const ResourceListCallback& callback) {
142 NOTREACHED(); 143 NOTREACHED();
143 } 144 }
144 145
(...skipping 10 matching lines...) Expand all
155 if (found != remote_resources_.end() && !found->second.deleted) { 156 if (found != remote_resources_.end() && !found->second.deleted) {
156 scoped_ptr<google_apis::ResourceEntry> entry( 157 scoped_ptr<google_apis::ResourceEntry> entry(
157 CreateResourceEntry(found->second)); 158 CreateResourceEntry(found->second));
158 file_md5 = entry->file_md5(); 159 file_md5 = entry->file_md5();
159 file_size = entry->file_size(); 160 file_size = entry->file_size();
160 updated_time = entry->updated_time(); 161 updated_time = entry->updated_time();
161 error = google_apis::HTTP_SUCCESS; 162 error = google_apis::HTTP_SUCCESS;
162 } 163 }
163 164
164 webkit_blob::ScopedFile dummy; 165 webkit_blob::ScopedFile dummy;
165 base::MessageLoopProxy::current()->PostTask( 166 base::ThreadTaskRunnerHandle::Get()->PostTask(
166 FROM_HERE, 167 FROM_HERE,
167 base::Bind(callback, error, file_md5, file_size, updated_time, 168 base::Bind(callback, error, file_md5, file_size, updated_time,
168 base::Passed(&dummy))); 169 base::Passed(&dummy)));
169 } 170 }
170 171
171 void FakeAPIUtil::UploadNewFile(const std::string& directory_resource_id, 172 void FakeAPIUtil::UploadNewFile(const std::string& directory_resource_id,
172 const base::FilePath& local_file_path, 173 const base::FilePath& local_file_path,
173 const std::string& title, 174 const std::string& title,
174 const UploadFileCallback& callback) { 175 const UploadFileCallback& callback) {
175 NOTREACHED(); 176 NOTREACHED();
(...skipping 11 matching lines...) Expand all
187 const ResourceIdCallback& callback) { 188 const ResourceIdCallback& callback) {
188 NOTREACHED(); 189 NOTREACHED();
189 } 190 }
190 191
191 bool FakeAPIUtil::IsAuthenticated() const { return true; } 192 bool FakeAPIUtil::IsAuthenticated() const { return true; }
192 193
193 void FakeAPIUtil::DeleteFile(const std::string& resource_id, 194 void FakeAPIUtil::DeleteFile(const std::string& resource_id,
194 const std::string& remote_file_md5, 195 const std::string& remote_file_md5,
195 const GDataErrorCallback& callback) { 196 const GDataErrorCallback& callback) {
196 if (!ContainsKey(remote_resources_, resource_id)) { 197 if (!ContainsKey(remote_resources_, resource_id)) {
197 base::MessageLoopProxy::current()->PostTask( 198 base::ThreadTaskRunnerHandle::Get()->PostTask(
198 FROM_HERE, 199 FROM_HERE,
199 base::Bind(callback, google_apis::HTTP_NOT_FOUND)); 200 base::Bind(callback, google_apis::HTTP_NOT_FOUND));
200 return; 201 return;
201 } 202 }
202 203
203 const RemoteResource& deleted_directory = remote_resources_[resource_id]; 204 const RemoteResource& deleted_directory = remote_resources_[resource_id];
204 PushRemoteChange(deleted_directory.parent_resource_id, 205 PushRemoteChange(deleted_directory.parent_resource_id,
205 deleted_directory.parent_title, 206 deleted_directory.parent_title,
206 deleted_directory.title, 207 deleted_directory.title,
207 deleted_directory.resource_id, 208 deleted_directory.resource_id,
208 deleted_directory.md5_checksum, 209 deleted_directory.md5_checksum,
209 SYNC_FILE_TYPE_UNKNOWN, 210 SYNC_FILE_TYPE_UNKNOWN,
210 true /* deleted */); 211 true /* deleted */);
211 212
212 base::MessageLoopProxy::current()->PostTask( 213 base::ThreadTaskRunnerHandle::Get()->PostTask(
213 FROM_HERE, 214 FROM_HERE,
214 base::Bind(callback, google_apis::HTTP_SUCCESS)); 215 base::Bind(callback, google_apis::HTTP_SUCCESS));
215 } 216 }
216 217
217 void FakeAPIUtil::EnsureSyncRootIsNotInMyDrive( 218 void FakeAPIUtil::EnsureSyncRootIsNotInMyDrive(
218 const std::string& sync_root_resource_id) { 219 const std::string& sync_root_resource_id) {
219 // Nothing to do. 220 // Nothing to do.
220 } 221 }
221 222
222 void FakeAPIUtil::PushRemoteChange(const std::string& parent_resource_id, 223 void FakeAPIUtil::PushRemoteChange(const std::string& parent_resource_id,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return entry.Pass(); 266 return entry.Pass();
266 } 267 }
267 268
268 GURL FakeAPIUtil::ResourceIdToResourceLink( 269 GURL FakeAPIUtil::ResourceIdToResourceLink(
269 const std::string& resource_id) const { 270 const std::string& resource_id) const {
270 return url_generator_.GenerateEditUrl(resource_id); 271 return url_generator_.GenerateEditUrl(resource_id);
271 } 272 }
272 273
273 } // namespace drive_backend 274 } // namespace drive_backend
274 } // namespace sync_file_system 275 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698