| 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 <stddef.h> |    7 #include <stddef.h> | 
|    8 #include <set> |    8 #include <set> | 
|    9 #include <string> |    9 #include <string> | 
|   10 #include <utility> |   10 #include <utility> | 
|   11  |   11  | 
|   12 #include "base/bind.h" |   12 #include "base/bind.h" | 
|   13 #include "base/files/file_util.h" |   13 #include "base/files/file_util.h" | 
|   14 #include "base/files/scoped_temp_dir.h" |   14 #include "base/files/scoped_temp_dir.h" | 
|   15 #include "base/format_macros.h" |   15 #include "base/format_macros.h" | 
|   16 #include "base/macros.h" |   16 #include "base/macros.h" | 
 |   17 #include "base/memory/ptr_util.h" | 
|   17 #include "base/message_loop/message_loop.h" |   18 #include "base/message_loop/message_loop.h" | 
|   18 #include "base/run_loop.h" |   19 #include "base/run_loop.h" | 
|   19 #include "base/strings/stringprintf.h" |   20 #include "base/strings/stringprintf.h" | 
|   20 #include "base/threading/thread_task_runner_handle.h" |   21 #include "base/threading/thread_task_runner_handle.h" | 
|   21 #include "base/time/time.h" |   22 #include "base/time/time.h" | 
|   22 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |   23 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 
|   23 #include "content/public/test/mock_special_storage_policy.h" |   24 #include "content/public/test/mock_special_storage_policy.h" | 
|   24 #include "content/public/test/test_browser_thread.h" |   25 #include "content/public/test/test_browser_thread.h" | 
|   25 #include "content/public/test/test_file_system_options.h" |   26 #include "content/public/test/test_file_system_options.h" | 
|   26 #include "storage/browser/fileapi/external_mount_points.h" |   27 #include "storage/browser/fileapi/external_mount_points.h" | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  120       : io_thread_(content::BrowserThread::IO, &message_loop_) { |  121       : io_thread_(content::BrowserThread::IO, &message_loop_) { | 
|  121   } |  122   } | 
|  122  |  123  | 
|  123   void SetUp() override { |  124   void SetUp() override { | 
|  124     ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |  125     ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 
|  125     ASSERT_TRUE(base::CreateDirectory(root_path())); |  126     ASSERT_TRUE(base::CreateDirectory(root_path())); | 
|  126  |  127  | 
|  127     scoped_refptr<storage::SpecialStoragePolicy> storage_policy = |  128     scoped_refptr<storage::SpecialStoragePolicy> storage_policy = | 
|  128         new content::MockSpecialStoragePolicy(); |  129         new content::MockSpecialStoragePolicy(); | 
|  129  |  130  | 
|  130     ScopedVector<storage::FileSystemBackend> additional_providers; |  131     std::vector<std::unique_ptr<storage::FileSystemBackend>> | 
|  131     additional_providers.push_back(new MediaFileSystemBackend( |  132         additional_providers; | 
 |  133     additional_providers.push_back(base::MakeUnique<MediaFileSystemBackend>( | 
|  132         data_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get())); |  134         data_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get())); | 
|  133  |  135  | 
|  134     file_system_context_ = new storage::FileSystemContext( |  136     file_system_context_ = new storage::FileSystemContext( | 
|  135         base::ThreadTaskRunnerHandle::Get().get(), |  137         base::ThreadTaskRunnerHandle::Get().get(), | 
|  136         base::ThreadTaskRunnerHandle::Get().get(), |  138         base::ThreadTaskRunnerHandle::Get().get(), | 
|  137         storage::ExternalMountPoints::CreateRefCounted().get(), |  139         storage::ExternalMountPoints::CreateRefCounted().get(), | 
|  138         storage_policy.get(), NULL, std::move(additional_providers), |  140         storage_policy.get(), NULL, std::move(additional_providers), | 
|  139         std::vector<storage::URLRequestAutoMountHandler>(), data_dir_.GetPath(), |  141         std::vector<storage::URLRequestAutoMountHandler>(), data_dir_.GetPath(), | 
|  140         content::CreateAllowFileAccessOptions()); |  142         content::CreateAllowFileAccessOptions()); | 
|  141  |  143  | 
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  566       expected_error = base::File::FILE_OK; |  568       expected_error = base::File::FILE_OK; | 
|  567     else |  569     else | 
|  568       expected_error = base::File::FILE_ERROR_SECURITY; |  570       expected_error = base::File::FILE_ERROR_SECURITY; | 
|  569     error = base::File::FILE_ERROR_FAILED; |  571     error = base::File::FILE_ERROR_FAILED; | 
|  570     operation_runner()->CreateSnapshotFile(url, |  572     operation_runner()->CreateSnapshotFile(url, | 
|  571         base::Bind(CreateSnapshotCallback, &error)); |  573         base::Bind(CreateSnapshotCallback, &error)); | 
|  572     base::RunLoop().RunUntilIdle(); |  574     base::RunLoop().RunUntilIdle(); | 
|  573     ASSERT_EQ(expected_error, error); |  575     ASSERT_EQ(expected_error, error); | 
|  574   } |  576   } | 
|  575 } |  577 } | 
| OLD | NEW |