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

Side by Side Diff: chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 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/media_galleries/fileapi/mtp_file_stream_reader.h" 5 #include "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" 10 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
11 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" 11 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h"
12 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" 12 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/mime_sniffer.h" 15 #include "net/base/mime_sniffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "webkit/browser/fileapi/file_system_context.h" 17 #include "storage/browser/fileapi/file_system_context.h"
18 18
19 using webkit_blob::FileStreamReader; 19 using storage::FileStreamReader;
20 20
21 namespace { 21 namespace {
22 22
23 // Called on the IO thread. 23 // Called on the IO thread.
24 MTPDeviceAsyncDelegate* GetMTPDeviceDelegate( 24 MTPDeviceAsyncDelegate* GetMTPDeviceDelegate(
25 const fileapi::FileSystemURL& url) { 25 const storage::FileSystemURL& url) {
26 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 26 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
27 return MTPDeviceMapService::GetInstance()->GetMTPDeviceAsyncDelegate( 27 return MTPDeviceMapService::GetInstance()->GetMTPDeviceAsyncDelegate(
28 url.filesystem_id()); 28 url.filesystem_id());
29 } 29 }
30 30
31 void CallCompletionCallbackWithPlatformFileError( 31 void CallCompletionCallbackWithPlatformFileError(
32 const net::CompletionCallback& callback, 32 const net::CompletionCallback& callback,
33 base::File::Error file_error) { 33 base::File::Error file_error) {
34 callback.Run(net::FileErrorToNetError(file_error)); 34 callback.Run(net::FileErrorToNetError(file_error));
35 } 35 }
36 36
37 void CallInt64CompletionCallbackWithPlatformFileError( 37 void CallInt64CompletionCallbackWithPlatformFileError(
38 const net::Int64CompletionCallback& callback, 38 const net::Int64CompletionCallback& callback,
39 base::File::Error file_error) { 39 base::File::Error file_error) {
40 callback.Run(net::FileErrorToNetError(file_error)); 40 callback.Run(net::FileErrorToNetError(file_error));
41 } 41 }
42 42
43 void ReadBytes( 43 void ReadBytes(
44 const fileapi::FileSystemURL& url, net::IOBuffer* buf, int64 offset, 44 const storage::FileSystemURL& url,
45 net::IOBuffer* buf,
46 int64 offset,
45 int buf_len, 47 int buf_len,
46 const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback, 48 const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback,
47 const net::CompletionCallback& error_callback) { 49 const net::CompletionCallback& error_callback) {
48 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 50 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
49 if (!delegate) { 51 if (!delegate) {
50 error_callback.Run(net::ERR_FAILED); 52 error_callback.Run(net::ERR_FAILED);
51 return; 53 return;
52 } 54 }
53 55
54 delegate->ReadBytes( 56 delegate->ReadBytes(
55 url.path(), 57 url.path(),
56 make_scoped_refptr(buf), 58 make_scoped_refptr(buf),
57 offset, 59 offset,
58 buf_len, 60 buf_len,
59 success_callback, 61 success_callback,
60 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback)); 62 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback));
61 } 63 }
62 64
63 } // namespace 65 } // namespace
64 66
65 MTPFileStreamReader::MTPFileStreamReader( 67 MTPFileStreamReader::MTPFileStreamReader(
66 fileapi::FileSystemContext* file_system_context, 68 storage::FileSystemContext* file_system_context,
67 const fileapi::FileSystemURL& url, 69 const storage::FileSystemURL& url,
68 int64 initial_offset, 70 int64 initial_offset,
69 const base::Time& expected_modification_time, 71 const base::Time& expected_modification_time,
70 bool do_media_header_validation) 72 bool do_media_header_validation)
71 : file_system_context_(file_system_context), 73 : file_system_context_(file_system_context),
72 url_(url), 74 url_(url),
73 current_offset_(initial_offset), 75 current_offset_(initial_offset),
74 expected_modification_time_(expected_modification_time), 76 expected_modification_time_(expected_modification_time),
75 media_header_validated_(!do_media_header_validation), 77 media_header_validated_(!do_media_header_validation),
76 weak_factory_(this) { 78 weak_factory_(this) {
77 } 79 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const base::File::Info& file_info) { 188 const base::File::Info& file_info) {
187 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 189 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
188 190
189 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { 191 if (!VerifySnapshotTime(expected_modification_time_, file_info)) {
190 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); 192 callback.Run(net::ERR_UPLOAD_FILE_CHANGED);
191 return; 193 return;
192 } 194 }
193 195
194 callback.Run(file_info.size); 196 callback.Run(file_info.size);
195 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698