OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/itunes_data_provider.h" | 5 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // are returned the xml file is not created. | 142 // are returned the xml file is not created. |
143 virtual std::vector<LibraryEntry> SetUpLibrary() { | 143 virtual std::vector<LibraryEntry> SetUpLibrary() { |
144 return std::vector<LibraryEntry>(); | 144 return std::vector<LibraryEntry>(); |
145 } | 145 } |
146 | 146 |
147 // Start the test. The data provider is refreshed before calling StartTest | 147 // Start the test. The data provider is refreshed before calling StartTest |
148 // and the result of the refresh is passed in. | 148 // and the result of the refresh is passed in. |
149 virtual void StartTest(bool parse_success) = 0; | 149 virtual void StartTest(bool parse_success) = 0; |
150 | 150 |
151 void TestDone() { | 151 void TestDone() { |
152 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 152 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); |
153 ImportedMediaGalleryRegistry* imported_registry = | 153 ImportedMediaGalleryRegistry* imported_registry = |
154 ImportedMediaGalleryRegistry::GetInstance(); | 154 ImportedMediaGalleryRegistry::GetInstance(); |
155 imported_registry->itunes_data_provider_.reset(); | 155 imported_registry->itunes_data_provider_.reset(); |
156 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 156 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
157 quit_closure_); | 157 quit_closure_); |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 void StartTestOnMediaTaskRunner() { | 161 void StartTestOnMediaTaskRunner() { |
162 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 162 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); |
163 ImportedMediaGalleryRegistry* imported_registry = | 163 ImportedMediaGalleryRegistry* imported_registry = |
164 ImportedMediaGalleryRegistry::GetInstance(); | 164 ImportedMediaGalleryRegistry::GetInstance(); |
165 imported_registry->itunes_data_provider_.reset( | 165 imported_registry->itunes_data_provider_.reset( |
166 new TestITunesDataProvider( | 166 new TestITunesDataProvider( |
167 XmlFile(), | 167 XmlFile(), |
168 base::Bind(&ITunesDataProviderTest::OnLibraryChanged, | 168 base::Bind(&ITunesDataProviderTest::OnLibraryChanged, |
169 base::Unretained(this)))); | 169 base::Unretained(this)))); |
170 data_provider()->RefreshData(base::Bind(&ITunesDataProviderTest::StartTest, | 170 data_provider()->RefreshData(base::Bind(&ITunesDataProviderTest::StartTest, |
171 base::Unretained(this))); | 171 base::Unretained(this))); |
172 } | 172 } |
173 | 173 |
174 void OnLibraryChanged() { | 174 void OnLibraryChanged() { |
175 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 175 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); |
176 if (!library_changed_callback_.is_null()) { | 176 if (!library_changed_callback_.is_null()) { |
177 library_changed_callback_.Run(); | 177 library_changed_callback_.Run(); |
178 library_changed_callback_.Reset(); | 178 library_changed_callback_.Reset(); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 void WriteLibraryInternal(const std::vector<LibraryEntry>& entries) { | 182 void WriteLibraryInternal(const std::vector<LibraryEntry>& entries) { |
183 if (entries.empty()) | 183 if (entries.empty()) |
184 return; | 184 return; |
185 std::string xml = "<plist><dict><key>Tracks</key><dict>\n"; | 185 std::string xml = "<plist><dict><key>Tracks</key><dict>\n"; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 462 |
463 IN_PROC_BROWSER_TEST_F(ITunesDataProviderUniqueNameTest, UniqueNameTest) { | 463 IN_PROC_BROWSER_TEST_F(ITunesDataProviderUniqueNameTest, UniqueNameTest) { |
464 RunTest(); | 464 RunTest(); |
465 } | 465 } |
466 | 466 |
467 IN_PROC_BROWSER_TEST_F(ITunesDataProviderEscapeTest, EscapeTest) { | 467 IN_PROC_BROWSER_TEST_F(ITunesDataProviderEscapeTest, EscapeTest) { |
468 RunTest(); | 468 RunTest(); |
469 } | 469 } |
470 | 470 |
471 } // namespace itunes | 471 } // namespace itunes |
OLD | NEW |