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

Side by Side Diff: content/child/fileapi/file_system_dispatcher.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/child/fileapi/file_system_dispatcher.h" 5 #include "content/child/fileapi/file_system_dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const StatusCallback& error_callback) { 70 const StatusCallback& error_callback) {
71 CallbackDispatcher* dispatcher = new CallbackDispatcher; 71 CallbackDispatcher* dispatcher = new CallbackDispatcher;
72 dispatcher->write_callback_ = callback; 72 dispatcher->write_callback_ = callback;
73 dispatcher->error_callback_ = error_callback; 73 dispatcher->error_callback_ = error_callback;
74 return dispatcher; 74 return dispatcher;
75 } 75 }
76 76
77 ~CallbackDispatcher() {} 77 ~CallbackDispatcher() {}
78 78
79 void DidSucceed() { 79 void DidSucceed() {
80 status_callback_.Run(base::PLATFORM_FILE_OK); 80 status_callback_.Run(base::File::FILE_OK);
81 } 81 }
82 82
83 void DidFail(base::PlatformFileError error_code) { 83 void DidFail(base::File::Error error_code) {
84 error_callback_.Run(error_code); 84 error_callback_.Run(error_code);
85 } 85 }
86 86
87 void DidReadMetadata( 87 void DidReadMetadata(
88 const base::PlatformFileInfo& file_info) { 88 const base::File::Info& file_info) {
89 metadata_callback_.Run(file_info); 89 metadata_callback_.Run(file_info);
90 } 90 }
91 91
92 void DidCreateSnapshotFile( 92 void DidCreateSnapshotFile(
93 const base::PlatformFileInfo& file_info, 93 const base::File::Info& file_info,
94 const base::FilePath& platform_path, 94 const base::FilePath& platform_path,
95 int request_id) { 95 int request_id) {
96 snapshot_callback_.Run(file_info, platform_path, request_id); 96 snapshot_callback_.Run(file_info, platform_path, request_id);
97 } 97 }
98 98
99 void DidReadDirectory( 99 void DidReadDirectory(
100 const std::vector<fileapi::DirectoryEntry>& entries, 100 const std::vector<fileapi::DirectoryEntry>& entries,
101 bool has_more) { 101 bool has_more) {
102 directory_callback_.Run(entries, has_more); 102 directory_callback_.Run(entries, has_more);
103 } 103 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 FileSystemDispatcher::FileSystemDispatcher() { 143 FileSystemDispatcher::FileSystemDispatcher() {
144 } 144 }
145 145
146 FileSystemDispatcher::~FileSystemDispatcher() { 146 FileSystemDispatcher::~FileSystemDispatcher() {
147 // Make sure we fire all the remaining callbacks. 147 // Make sure we fire all the remaining callbacks.
148 for (IDMap<CallbackDispatcher, IDMapOwnPointer>::iterator 148 for (IDMap<CallbackDispatcher, IDMapOwnPointer>::iterator
149 iter(&dispatchers_); !iter.IsAtEnd(); iter.Advance()) { 149 iter(&dispatchers_); !iter.IsAtEnd(); iter.Advance()) {
150 int request_id = iter.GetCurrentKey(); 150 int request_id = iter.GetCurrentKey();
151 CallbackDispatcher* dispatcher = iter.GetCurrentValue(); 151 CallbackDispatcher* dispatcher = iter.GetCurrentValue();
152 DCHECK(dispatcher); 152 DCHECK(dispatcher);
153 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_ABORT); 153 dispatcher->DidFail(base::File::FILE_ERROR_ABORT);
154 dispatchers_.Remove(request_id); 154 dispatchers_.Remove(request_id);
155 } 155 }
156 } 156 }
157 157
158 bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) { 158 bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) {
159 bool handled = true; 159 bool handled = true;
160 IPC_BEGIN_MESSAGE_MAP(FileSystemDispatcher, msg) 160 IPC_BEGIN_MESSAGE_MAP(FileSystemDispatcher, msg)
161 IPC_MESSAGE_HANDLER(FileSystemMsg_DidOpenFileSystem, OnDidOpenFileSystem) 161 IPC_MESSAGE_HANDLER(FileSystemMsg_DidOpenFileSystem, OnDidOpenFileSystem)
162 IPC_MESSAGE_HANDLER(FileSystemMsg_DidResolveURL, OnDidResolveURL) 162 IPC_MESSAGE_HANDLER(FileSystemMsg_DidResolveURL, OnDidResolveURL)
163 IPC_MESSAGE_HANDLER(FileSystemMsg_DidSucceed, OnDidSucceed) 163 IPC_MESSAGE_HANDLER(FileSystemMsg_DidSucceed, OnDidSucceed)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 360 }
361 361
362 void FileSystemDispatcher::OnDidSucceed(int request_id) { 362 void FileSystemDispatcher::OnDidSucceed(int request_id) {
363 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 363 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
364 DCHECK(dispatcher); 364 DCHECK(dispatcher);
365 dispatcher->DidSucceed(); 365 dispatcher->DidSucceed();
366 dispatchers_.Remove(request_id); 366 dispatchers_.Remove(request_id);
367 } 367 }
368 368
369 void FileSystemDispatcher::OnDidReadMetadata( 369 void FileSystemDispatcher::OnDidReadMetadata(
370 int request_id, const base::PlatformFileInfo& file_info) { 370 int request_id, const base::File::Info& file_info) {
371 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 371 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
372 DCHECK(dispatcher); 372 DCHECK(dispatcher);
373 dispatcher->DidReadMetadata(file_info); 373 dispatcher->DidReadMetadata(file_info);
374 dispatchers_.Remove(request_id); 374 dispatchers_.Remove(request_id);
375 } 375 }
376 376
377 void FileSystemDispatcher::OnDidCreateSnapshotFile( 377 void FileSystemDispatcher::OnDidCreateSnapshotFile(
378 int request_id, const base::PlatformFileInfo& file_info, 378 int request_id, const base::File::Info& file_info,
379 const base::FilePath& platform_path) { 379 const base::FilePath& platform_path) {
380 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 380 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
381 DCHECK(dispatcher); 381 DCHECK(dispatcher);
382 dispatcher->DidCreateSnapshotFile(file_info, platform_path, request_id); 382 dispatcher->DidCreateSnapshotFile(file_info, platform_path, request_id);
383 dispatchers_.Remove(request_id); 383 dispatchers_.Remove(request_id);
384 } 384 }
385 385
386 void FileSystemDispatcher::OnDidReadDirectory( 386 void FileSystemDispatcher::OnDidReadDirectory(
387 int request_id, 387 int request_id,
388 const std::vector<fileapi::DirectoryEntry>& entries, 388 const std::vector<fileapi::DirectoryEntry>& entries,
389 bool has_more) { 389 bool has_more) {
390 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 390 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
391 DCHECK(dispatcher); 391 DCHECK(dispatcher);
392 dispatcher->DidReadDirectory(entries, has_more); 392 dispatcher->DidReadDirectory(entries, has_more);
393 dispatchers_.Remove(request_id); 393 dispatchers_.Remove(request_id);
394 } 394 }
395 395
396 void FileSystemDispatcher::OnDidFail( 396 void FileSystemDispatcher::OnDidFail(
397 int request_id, base::PlatformFileError error_code) { 397 int request_id, base::File::Error error_code) {
398 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 398 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
399 DCHECK(dispatcher); 399 DCHECK(dispatcher);
400 dispatcher->DidFail(error_code); 400 dispatcher->DidFail(error_code);
401 dispatchers_.Remove(request_id); 401 dispatchers_.Remove(request_id);
402 } 402 }
403 403
404 void FileSystemDispatcher::OnDidWrite( 404 void FileSystemDispatcher::OnDidWrite(
405 int request_id, int64 bytes, bool complete) { 405 int request_id, int64 bytes, bool complete) {
406 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 406 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
407 DCHECK(dispatcher); 407 DCHECK(dispatcher);
408 dispatcher->DidWrite(bytes, complete); 408 dispatcher->DidWrite(bytes, complete);
409 if (complete) 409 if (complete)
410 dispatchers_.Remove(request_id); 410 dispatchers_.Remove(request_id);
411 } 411 }
412 412
413 void FileSystemDispatcher::OnDidOpenFile( 413 void FileSystemDispatcher::OnDidOpenFile(
414 int request_id, 414 int request_id,
415 IPC::PlatformFileForTransit file, 415 IPC::PlatformFileForTransit file,
416 int file_open_id, 416 int file_open_id,
417 quota::QuotaLimitType quota_policy) { 417 quota::QuotaLimitType quota_policy) {
418 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 418 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
419 DCHECK(dispatcher); 419 DCHECK(dispatcher);
420 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file), 420 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file),
421 file_open_id, 421 file_open_id,
422 quota_policy); 422 quota_policy);
423 dispatchers_.Remove(request_id); 423 dispatchers_.Remove(request_id);
424 } 424 }
425 425
426 } // namespace content 426 } // namespace content
OLDNEW
« no previous file with comments | « content/child/fileapi/file_system_dispatcher.h ('k') | content/child/fileapi/webfilesystem_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698