| OLD | NEW |
| 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 "chrome/browser/media_galleries/fileapi/native_media_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 16 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 19 #include "net/base/mime_sniffer.h" | 19 #include "net/base/mime_sniffer.h" |
| 20 #include "storage/browser/blob/shareable_file_reference.h" | 20 #include "storage/browser/blob/shareable_file_reference.h" |
| 21 #include "storage/browser/fileapi/file_system_context.h" | 21 #include "storage/browser/fileapi/file_system_context.h" |
| 22 #include "storage/browser/fileapi/file_system_operation_context.h" | 22 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 23 #include "storage/browser/fileapi/native_file_util.h" | 23 #include "storage/browser/fileapi/native_file_util.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Returns true if the current thread is capable of doing IO. | 28 // Returns true if the current thread is capable of doing IO. |
| 29 bool IsOnTaskRunnerThread(storage::FileSystemOperationContext* context) { | 29 bool IsOnTaskRunnerThread(storage::FileSystemOperationContext* context) { |
| 30 return context->task_runner()->RunsTasksOnCurrentThread(); | 30 return context->task_runner()->RunsTasksInCurrentSequence(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 base::File::Error IsMediaHeader(const char* buf, size_t length) { | 33 base::File::Error IsMediaHeader(const char* buf, size_t length) { |
| 34 if (length == 0) | 34 if (length == 0) |
| 35 return base::File::FILE_ERROR_SECURITY; | 35 return base::File::FILE_ERROR_SECURITY; |
| 36 | 36 |
| 37 std::string mime_type; | 37 std::string mime_type; |
| 38 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type)) | 38 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type)) |
| 39 return base::File::FILE_ERROR_SECURITY; | 39 return base::File::FILE_ERROR_SECURITY; |
| 40 | 40 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 return base::File::FILE_ERROR_FAILED; | 656 return base::File::FILE_ERROR_FAILED; |
| 657 | 657 |
| 658 if (!file_info.is_directory && | 658 if (!file_info.is_directory && |
| 659 !media_path_filter_->Match(file_path)) { | 659 !media_path_filter_->Match(file_path)) { |
| 660 return failure_error; | 660 return failure_error; |
| 661 } | 661 } |
| 662 | 662 |
| 663 *local_file_path = file_path; | 663 *local_file_path = file_path; |
| 664 return base::File::FILE_OK; | 664 return base::File::FILE_OK; |
| 665 } | 665 } |
| OLD | NEW |