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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 MessageLoop::current()->Run(); | 93 MessageLoop::current()->Run(); |
94 } | 94 } |
95 | 95 |
96 // Unblocks the current MessageLoop. Should be called in response to some sort | 96 // Unblocks the current MessageLoop. Should be called in response to some sort |
97 // of async activity in a callback method. | 97 // of async activity in a callback method. |
98 void Notify() { | 98 void Notify() { |
99 MessageLoop::current()->Quit(); | 99 MessageLoop::current()->Quit(); |
100 } | 100 } |
101 | 101 |
102 // Callback that should be executed in response to | 102 // Callback that should be executed in response to |
103 // fileapi::SandboxMountPointProvider::ValidateFileSystemRoot | 103 // fileapi::SandboxMountPointProvider::OpenFileSystem. |
104 void ValidateFileSystemCallback(base::PlatformFileError error) { | 104 void OpenFileSystemCallback(base::PlatformFileError error) { |
105 validate_file_system_result_ = error; | 105 open_file_system_result_ = error; |
106 Notify(); | 106 Notify(); |
107 } | 107 } |
108 | 108 |
109 // Calls fileapi::SandboxMountPointProvider::ValidateFileSystemRootAndGetURL | 109 // Calls fileapi::SandboxMountPointProvider::OpenFileSystem |
110 // to verify the existence of a file system for a specified type and origin, | 110 // to verify the existence of a file system for a specified type and origin, |
111 // blocks until a response is available, then returns the result | 111 // blocks until a response is available, then returns the result |
112 // synchronously to it's caller. | 112 // synchronously to it's caller. |
113 bool FileSystemContainsOriginAndType(const GURL& origin, | 113 bool FileSystemContainsOriginAndType(const GURL& origin, |
114 fileapi::FileSystemType type) { | 114 fileapi::FileSystemType type) { |
115 sandbox_->ValidateFileSystemRoot( | 115 sandbox_->OpenFileSystem( |
116 origin, type, false, | 116 origin, type, |
| 117 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, |
117 base::Bind( | 118 base::Bind( |
118 &BrowsingDataFileSystemHelperTest::ValidateFileSystemCallback, | 119 &BrowsingDataFileSystemHelperTest::OpenFileSystemCallback, |
119 base::Unretained(this))); | 120 base::Unretained(this))); |
120 BlockUntilNotified(); | 121 BlockUntilNotified(); |
121 return validate_file_system_result_ == base::PLATFORM_FILE_OK; | 122 return open_file_system_result_ == base::PLATFORM_FILE_OK; |
122 } | 123 } |
123 | 124 |
124 // Callback that should be executed in response to StartFetching(), and stores | 125 // Callback that should be executed in response to StartFetching(), and stores |
125 // found file systems locally so that they are available via GetFileSystems(). | 126 // found file systems locally so that they are available via GetFileSystems(). |
126 void CallbackStartFetching( | 127 void CallbackStartFetching( |
127 const std::list<BrowsingDataFileSystemHelper::FileSystemInfo>& | 128 const std::list<BrowsingDataFileSystemHelper::FileSystemInfo>& |
128 file_system_info_list) { | 129 file_system_info_list) { |
129 file_system_info_list_.reset( | 130 file_system_info_list_.reset( |
130 new std::list<BrowsingDataFileSystemHelper::FileSystemInfo>( | 131 new std::list<BrowsingDataFileSystemHelper::FileSystemInfo>( |
131 file_system_info_list)); | 132 file_system_info_list)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 180 } |
180 | 181 |
181 // Returns a list of the FileSystemInfo objects gathered in the most recent | 182 // Returns a list of the FileSystemInfo objects gathered in the most recent |
182 // call to StartFetching(). | 183 // call to StartFetching(). |
183 FileSystemInfoList* GetFileSystems() { | 184 FileSystemInfoList* GetFileSystems() { |
184 return file_system_info_list_.get(); | 185 return file_system_info_list_.get(); |
185 } | 186 } |
186 | 187 |
187 | 188 |
188 // Temporary storage to pass information back from callbacks. | 189 // Temporary storage to pass information back from callbacks. |
189 base::PlatformFileError validate_file_system_result_; | 190 base::PlatformFileError open_file_system_result_; |
190 ScopedFileSystemInfoList file_system_info_list_; | 191 ScopedFileSystemInfoList file_system_info_list_; |
191 | 192 |
192 scoped_refptr<BrowsingDataFileSystemHelper> helper_; | 193 scoped_refptr<BrowsingDataFileSystemHelper> helper_; |
193 scoped_refptr<CannedBrowsingDataFileSystemHelper> canned_helper_; | 194 scoped_refptr<CannedBrowsingDataFileSystemHelper> canned_helper_; |
194 | 195 |
195 private: | 196 private: |
196 // message_loop_, as well as all the threads associated with it must be | 197 // message_loop_, as well as all the threads associated with it must be |
197 // defined before profile_ to prevent explosions. The threads also must be | 198 // defined before profile_ to prevent explosions. The threads also must be |
198 // defined in the order they're listed here. Oh how I love C++. | 199 // defined in the order they're listed here. Oh how I love C++. |
199 MessageLoopForUI message_loop_; | 200 MessageLoopForUI message_loop_; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // extension and devtools schemes. | 315 // extension and devtools schemes. |
315 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { | 316 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { |
316 ASSERT_TRUE(canned_helper_->empty()); | 317 ASSERT_TRUE(canned_helper_->empty()); |
317 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); | 318 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); |
318 ASSERT_TRUE(canned_helper_->empty()); | 319 ASSERT_TRUE(canned_helper_->empty()); |
319 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); | 320 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); |
320 ASSERT_TRUE(canned_helper_->empty()); | 321 ASSERT_TRUE(canned_helper_->empty()); |
321 } | 322 } |
322 | 323 |
323 } // namespace | 324 } // namespace |
OLD | NEW |