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

Side by Side Diff: net/url_request/url_request_file_job.cc

Issue 739033003: Support content scheme uri for Chrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 6 years, 1 month 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 (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 // For loading files, we make use of overlapped i/o to ensure that reading from 5 // For loading files, we make use of overlapped i/o to ensure that reading from
6 // the filesystem (e.g., a network filesystem) does not block the calling 6 // the filesystem (e.g., a network filesystem) does not block the calling
7 // thread. An alternative approach would be to use a background thread or pool 7 // thread. An alternative approach would be to use a background thread or pool
8 // of threads, but it seems better to leverage the operating system's ability 8 // of threads, but it seems better to leverage the operating system's ability
9 // to do background file reads for us. 9 // to do background file reads for us.
10 // 10 //
(...skipping 23 matching lines...) Expand all
34 #include "net/base/io_buffer.h" 34 #include "net/base/io_buffer.h"
35 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
36 #include "net/base/mime_util.h" 36 #include "net/base/mime_util.h"
37 #include "net/base/net_errors.h" 37 #include "net/base/net_errors.h"
38 #include "net/filter/filter.h" 38 #include "net/filter/filter.h"
39 #include "net/http/http_util.h" 39 #include "net/http/http_util.h"
40 #include "net/url_request/url_request_error_job.h" 40 #include "net/url_request/url_request_error_job.h"
41 #include "net/url_request/url_request_file_dir_job.h" 41 #include "net/url_request/url_request_file_dir_job.h"
42 #include "url/gurl.h" 42 #include "url/gurl.h"
43 43
44 #if defined(OS_ANDROID)
45 #include "base/android/content_uri_utils.h"
46 #endif
47
44 #if defined(OS_WIN) 48 #if defined(OS_WIN)
45 #include "base/win/shortcut.h" 49 #include "base/win/shortcut.h"
46 #endif 50 #endif
47 51
48 namespace net { 52 namespace net {
49 53
50 URLRequestFileJob::FileMetaInfo::FileMetaInfo() 54 URLRequestFileJob::FileMetaInfo::FileMetaInfo()
51 : file_size(0), 55 : file_size(0),
52 mime_type_result(false), 56 mime_type_result(false),
53 file_exists(false), 57 file_exists(false),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 210 }
207 211
208 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, 212 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path,
209 FileMetaInfo* meta_info) { 213 FileMetaInfo* meta_info) {
210 base::File::Info file_info; 214 base::File::Info file_info;
211 meta_info->file_exists = base::GetFileInfo(file_path, &file_info); 215 meta_info->file_exists = base::GetFileInfo(file_path, &file_info);
212 if (meta_info->file_exists) { 216 if (meta_info->file_exists) {
213 meta_info->file_size = file_info.size; 217 meta_info->file_size = file_info.size;
214 meta_info->is_directory = file_info.is_directory; 218 meta_info->is_directory = file_info.is_directory;
215 } 219 }
220 #if defined(OS_ANDROID)
221 if (file_path.IsContentUri()) {
asanka 2014/11/21 02:22:02 If this extra logic is required for a FilePath tha
222 if (meta_info->file_exists) {
223 meta_info->mime_type = base::GetContentUriMimeType(file_path);
224 meta_info->mime_type_result = !meta_info->mime_type.empty();
225 }
226 return;
227 }
228 #endif
216 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be 229 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be
217 // done in WorkerPool. 230 // done in WorkerPool.
218 meta_info->mime_type_result = GetMimeTypeFromFile(file_path, 231 meta_info->mime_type_result = GetMimeTypeFromFile(file_path,
219 &meta_info->mime_type); 232 &meta_info->mime_type);
220 } 233 }
221 234
222 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { 235 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
223 meta_info_ = *meta_info; 236 meta_info_ = *meta_info;
224 237
225 // We use URLRequestFileJob to handle files as well as directories without 238 // We use URLRequestFileJob to handle files as well as directories without
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (result == 0) { 330 if (result == 0) {
318 NotifyDone(URLRequestStatus()); 331 NotifyDone(URLRequestStatus());
319 } else if (result < 0) { 332 } else if (result < 0) {
320 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); 333 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
321 } 334 }
322 335
323 NotifyReadComplete(result); 336 NotifyReadComplete(result);
324 } 337 }
325 338
326 } // namespace net 339 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698