Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/media_galleries/media_file_system_registry_unittest.cc

Issue 24269007: Media Galleries API: Fix MediaGalleriesPreferences finders race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // MediaFileSystemRegistry unit tests. 5 // MediaFileSystemRegistry unit tests.
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // delete everything that references the profile. 465 // delete everything that references the profile.
466 single_web_contents_.reset(); 466 single_web_contents_.reset();
467 shared_web_contents1_.reset(); 467 shared_web_contents1_.reset();
468 shared_web_contents2_.reset(); 468 shared_web_contents2_.reset();
469 profile_.reset(); 469 profile_.reset();
470 470
471 base::MessageLoop::current()->RunUntilIdle(); 471 base::MessageLoop::current()->RunUntilIdle();
472 } 472 }
473 473
474 MediaGalleriesPreferences* ProfileState::GetMediaGalleriesPrefs() { 474 MediaGalleriesPreferences* ProfileState::GetMediaGalleriesPrefs() {
475 return MediaGalleriesPreferencesFactory::GetForProfile(profile_.get()); 475 MediaGalleriesPreferences* prefs =
476 MediaGalleriesPreferencesFactory::GetForProfile(profile_.get());
477 base::RunLoop loop;
478 prefs->EnsureInitialized(loop.QuitClosure());
479 loop.Run();
480 return prefs;
476 } 481 }
477 482
478 void ProfileState::CheckGalleries( 483 void ProfileState::CheckGalleries(
479 const std::string& test, 484 const std::string& test,
480 const std::vector<MediaFileSystemInfo>& regular_extension_galleries, 485 const std::vector<MediaFileSystemInfo>& regular_extension_galleries,
481 const std::vector<MediaFileSystemInfo>& all_extension_galleries) { 486 const std::vector<MediaFileSystemInfo>& all_extension_galleries) {
482 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); 487 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost();
483 MediaFileSystemRegistry* registry = 488 MediaFileSystemRegistry* registry =
484 g_browser_process->media_file_system_registry(); 489 g_browser_process->media_file_system_registry();
485 490
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 profile_states_.push_back(state); 597 profile_states_.push_back(state);
593 } 598 }
594 } 599 }
595 600
596 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) { 601 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) {
597 return profile_states_[i]; 602 return profile_states_[i];
598 } 603 }
599 604
600 MediaGalleriesPreferences* MediaFileSystemRegistryTest::GetPreferences( 605 MediaGalleriesPreferences* MediaFileSystemRegistryTest::GetPreferences(
601 Profile* profile) { 606 Profile* profile) {
602 return registry()->GetPreferences(profile); 607 MediaGalleriesPreferences* prefs = registry()->GetPreferences(profile);
608 base::RunLoop loop;
609 prefs->EnsureInitialized(loop.QuitClosure());
610 loop.Run();
611 return prefs;
603 } 612 }
604 613
605 std::string MediaFileSystemRegistryTest::AddUserGallery( 614 std::string MediaFileSystemRegistryTest::AddUserGallery(
606 StorageInfo::Type type, 615 StorageInfo::Type type,
607 const std::string& unique_id, 616 const std::string& unique_id,
608 const base::FilePath& path) { 617 const base::FilePath& path) {
609 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); 618 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id);
610 DCHECK(!StorageInfo::IsMediaDevice(device_id)); 619 DCHECK(!StorageInfo::IsMediaDevice(device_id));
611 620
612 for (size_t i = 0; i < profile_states_.size(); ++i) { 621 for (size_t i = 0; i < profile_states_.size(); ++i) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_PICTURES, &path)); 1030 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_PICTURES, &path));
1022 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); 1031 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName());
1023 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_VIDEOS, &path)); 1032 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_VIDEOS, &path));
1024 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); 1033 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName());
1025 1034
1026 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries); 1035 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries);
1027 } else { 1036 } else {
1028 profile_state->CheckGalleries("names", one_expectation, one_expectation); 1037 profile_state->CheckGalleries("names", one_expectation, one_expectation);
1029 } 1038 }
1030 } 1039 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698