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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc

Issue 1119803007: [chrome/browser/chromeos] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nit Created 5 years, 7 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
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 "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h" 5 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/single_thread_task_runner.h"
Daniel Erat 2015/05/05 15:17:03 why is this included? it doesn't look like it's us
Pranay 2015/05/06 05:48:50 File removed from patch due to cancelable_task dep
8 #include "base/thread_task_runner_handle.h"
8 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
9 10
10 namespace chromeos { 11 namespace chromeos {
11 namespace file_system_provider { 12 namespace file_system_provider {
12 namespace { 13 namespace {
13 14
14 const char kFakeFileName[] = "hello.txt"; 15 const char kFakeFileName[] = "hello.txt";
15 const char kFakeFileText[] = 16 const char kFakeFileText[] =
16 "This is a testing file. Lorem ipsum dolor sit amet est."; 17 "This is a testing file. Lorem ipsum dolor sit amet est.";
17 const size_t kFakeFileSize = sizeof(kFakeFileText) - 1u; 18 const size_t kFakeFileSize = sizeof(kFakeFileText) - 1u;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 false /* has_more */, 202 false /* has_more */,
202 base::File::FILE_OK)); 203 base::File::FILE_OK));
203 } 204 }
204 205
205 const FakeEntry* const entry = entry_it->second.get(); 206 const FakeEntry* const entry = entry_it->second.get();
206 std::vector<int> task_ids; 207 std::vector<int> task_ids;
207 while (current_offset < entry->metadata->size && current_length) { 208 while (current_offset < entry->metadata->size && current_length) {
208 buffer->data()[current_offset - offset] = entry->contents[current_offset]; 209 buffer->data()[current_offset - offset] = entry->contents[current_offset];
209 const bool has_more = 210 const bool has_more =
210 (current_offset + 1 < entry->metadata->size) && (current_length - 1); 211 (current_offset + 1 < entry->metadata->size) && (current_length - 1);
211 const int task_id = tracker_.PostTask( 212 const int task_id =
212 base::MessageLoopProxy::current().get(), 213 tracker_.PostTask(base::ThreadTaskRunnerHandle::Get(), FROM_HERE,
213 FROM_HERE, 214 base::Bind(callback, 1 /* chunk_length */, has_more,
214 base::Bind( 215 base::File::FILE_OK));
215 callback, 1 /* chunk_length */, has_more, base::File::FILE_OK));
216 task_ids.push_back(task_id); 216 task_ids.push_back(task_id);
217 current_offset++; 217 current_offset++;
218 current_length--; 218 current_length--;
219 } 219 }
220 220
221 return base::Bind(&FakeProvidedFileSystem::AbortMany, 221 return base::Bind(&FakeProvidedFileSystem::AbortMany,
222 weak_ptr_factory_.GetWeakPtr(), 222 weak_ptr_factory_.GetWeakPtr(),
223 task_ids); 223 task_ids);
224 } 224 }
225 225
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return new FakeProvidedFileSystem(file_system_info); 384 return new FakeProvidedFileSystem(file_system_info);
385 } 385 }
386 386
387 base::WeakPtr<ProvidedFileSystemInterface> 387 base::WeakPtr<ProvidedFileSystemInterface>
388 FakeProvidedFileSystem::GetWeakPtr() { 388 FakeProvidedFileSystem::GetWeakPtr() {
389 return weak_ptr_factory_.GetWeakPtr(); 389 return weak_ptr_factory_.GetWeakPtr();
390 } 390 }
391 391
392 AbortCallback FakeProvidedFileSystem::PostAbortableTask( 392 AbortCallback FakeProvidedFileSystem::PostAbortableTask(
393 const base::Closure& callback) { 393 const base::Closure& callback) {
394 const int task_id = tracker_.PostTask( 394 const int task_id = tracker_.PostTask(base::ThreadTaskRunnerHandle::Get(),
395 base::MessageLoopProxy::current().get(), FROM_HERE, callback); 395 FROM_HERE, callback);
396 return base::Bind( 396 return base::Bind(
397 &FakeProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), task_id); 397 &FakeProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), task_id);
398 } 398 }
399 399
400 void FakeProvidedFileSystem::Abort(int task_id) { 400 void FakeProvidedFileSystem::Abort(int task_id) {
401 tracker_.TryCancel(task_id); 401 tracker_.TryCancel(task_id);
402 } 402 }
403 403
404 void FakeProvidedFileSystem::AbortMany(const std::vector<int>& task_ids) { 404 void FakeProvidedFileSystem::AbortMany(const std::vector<int>& task_ids) {
405 for (size_t i = 0; i < task_ids.size(); ++i) { 405 for (size_t i = 0; i < task_ids.size(); ++i) {
406 tracker_.TryCancel(task_ids[i]); 406 tracker_.TryCancel(task_ids[i]);
407 } 407 }
408 } 408 }
409 409
410 } // namespace file_system_provider 410 } // namespace file_system_provider
411 } // namespace chromeos 411 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698