OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/file_system_provider/throttled_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/throttled_file_system.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/files/file.h" | 12 #include "base/files/file.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/ptr_util.h" |
13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
14 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" | 15 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" |
15 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 16 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
16 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 17 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
17 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 18 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
18 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace chromeos { | 22 namespace chromeos { |
22 namespace file_system_provider { | 23 namespace file_system_provider { |
(...skipping 30 matching lines...) Expand all Loading... |
53 void SetUpFileSystem(size_t limit) { | 54 void SetUpFileSystem(size_t limit) { |
54 MountOptions options(kFileSystemId, kDisplayName); | 55 MountOptions options(kFileSystemId, kDisplayName); |
55 options.opened_files_limit = limit; | 56 options.opened_files_limit = limit; |
56 | 57 |
57 ProvidedFileSystemInfo file_system_info( | 58 ProvidedFileSystemInfo file_system_info( |
58 kExtensionId, options, base::FilePath() /* mount_path */, | 59 kExtensionId, options, base::FilePath() /* mount_path */, |
59 false /* configurable */, true /* watchable */, | 60 false /* configurable */, true /* watchable */, |
60 extensions::SOURCE_FILE); | 61 extensions::SOURCE_FILE); |
61 | 62 |
62 file_system_.reset(new ThrottledFileSystem( | 63 file_system_.reset(new ThrottledFileSystem( |
63 make_scoped_ptr(new FakeProvidedFileSystem(file_system_info)))); | 64 base::WrapUnique(new FakeProvidedFileSystem(file_system_info)))); |
64 } | 65 } |
65 | 66 |
66 content::TestBrowserThreadBundle thread_bundle_; | 67 content::TestBrowserThreadBundle thread_bundle_; |
67 scoped_ptr<ThrottledFileSystem> file_system_; | 68 std::unique_ptr<ThrottledFileSystem> file_system_; |
68 }; | 69 }; |
69 | 70 |
70 TEST_F(FileSystemProviderThrottledFileSystemTest, OpenFile_LimitedToOneAtOnce) { | 71 TEST_F(FileSystemProviderThrottledFileSystemTest, OpenFile_LimitedToOneAtOnce) { |
71 SetUpFileSystem(1); | 72 SetUpFileSystem(1); |
72 | 73 |
73 OpenLog first_open_log; | 74 OpenLog first_open_log; |
74 file_system_->OpenFile(base::FilePath(kFakeFilePath), OPEN_FILE_MODE_READ, | 75 file_system_->OpenFile(base::FilePath(kFakeFilePath), OPEN_FILE_MODE_READ, |
75 base::Bind(&LogOpen, &first_open_log)); | 76 base::Bind(&LogOpen, &first_open_log)); |
76 | 77 |
77 OpenLog second_open_log; | 78 OpenLog second_open_log; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 153 |
153 base::RunLoop().RunUntilIdle(); | 154 base::RunLoop().RunUntilIdle(); |
154 | 155 |
155 ASSERT_EQ(1u, first_open_log.size()); | 156 ASSERT_EQ(1u, first_open_log.size()); |
156 EXPECT_EQ(base::File::FILE_OK, first_open_log[0].second); | 157 EXPECT_EQ(base::File::FILE_OK, first_open_log[0].second); |
157 EXPECT_EQ(0u, second_open_log.size()); | 158 EXPECT_EQ(0u, second_open_log.size()); |
158 } | 159 } |
159 | 160 |
160 } // namespace file_system_provider | 161 } // namespace file_system_provider |
161 } // namespace chromeos | 162 } // namespace chromeos |
OLD | NEW |