Commit caca7b86 authored by Fabrice de Gans-Riberi's avatar Fabrice de Gans-Riberi Committed by Commit Bot

[fuchsia] Remove fuchsia sub-namespace from IntlProfileWatcher

This renames the class FuchsiaIntlProfileWatcher.

Bug: 1073821
Change-Id: I13a5eb3bd71de69b00e447742400d26f3877755d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431732
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#815850}
parent 2be063ba
...@@ -16,15 +16,16 @@ ...@@ -16,15 +16,16 @@
using ::fuchsia::intl::Profile; using ::fuchsia::intl::Profile;
namespace base { namespace base {
namespace fuchsia {
IntlProfileWatcher::IntlProfileWatcher(ProfileChangeCallback on_profile_changed) FuchsiaIntlProfileWatcher::FuchsiaIntlProfileWatcher(
: IntlProfileWatcher(ComponentContextForProcess() ProfileChangeCallback on_profile_changed)
: FuchsiaIntlProfileWatcher(
ComponentContextForProcess()
->svc() ->svc()
->Connect<::fuchsia::intl::PropertyProvider>(), ->Connect<::fuchsia::intl::PropertyProvider>(),
on_profile_changed) {} on_profile_changed) {}
IntlProfileWatcher::IntlProfileWatcher( FuchsiaIntlProfileWatcher::FuchsiaIntlProfileWatcher(
::fuchsia::intl::PropertyProviderPtr property_provider, ::fuchsia::intl::PropertyProviderPtr property_provider,
ProfileChangeCallback on_profile_changed) ProfileChangeCallback on_profile_changed)
: property_provider_(std::move(property_provider)), : property_provider_(std::move(property_provider)),
...@@ -43,10 +44,10 @@ IntlProfileWatcher::IntlProfileWatcher( ...@@ -43,10 +44,10 @@ IntlProfileWatcher::IntlProfileWatcher(
}; };
} }
IntlProfileWatcher::~IntlProfileWatcher() = default; FuchsiaIntlProfileWatcher::~FuchsiaIntlProfileWatcher() = default;
// static // static
std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile( std::string FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
const Profile& profile) { const Profile& profile) {
if (!profile.has_time_zones()) { if (!profile.has_time_zones()) {
DLOG(WARNING) << "Profile does not contain time zones."; DLOG(WARNING) << "Profile does not contain time zones.";
...@@ -64,14 +65,15 @@ std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile( ...@@ -64,14 +65,15 @@ std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
} }
// static // static
std::string IntlProfileWatcher::GetPrimaryTimeZoneIdForIcuInitialization() { std::string
FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdForIcuInitialization() {
::fuchsia::intl::PropertyProviderSyncPtr provider; ::fuchsia::intl::PropertyProviderSyncPtr provider;
ComponentContextForProcess()->svc()->Connect(provider.NewRequest()); ComponentContextForProcess()->svc()->Connect(provider.NewRequest());
return GetPrimaryTimeZoneIdFromPropertyProvider(std::move(provider)); return GetPrimaryTimeZoneIdFromPropertyProvider(std::move(provider));
} }
// static // static
std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider( std::string FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider(
::fuchsia::intl::PropertyProviderSyncPtr property_provider) { ::fuchsia::intl::PropertyProviderSyncPtr property_provider) {
DCHECK(property_provider.is_bound()); DCHECK(property_provider.is_bound());
Profile profile; Profile profile;
...@@ -84,5 +86,4 @@ std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider( ...@@ -84,5 +86,4 @@ std::string IntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider(
return GetPrimaryTimeZoneIdFromProfile(profile); return GetPrimaryTimeZoneIdFromProfile(profile);
} }
} // namespace fuchsia
} // namespace base } // namespace base
...@@ -13,22 +13,22 @@ ...@@ -13,22 +13,22 @@
#include "base/strings/string_piece_forward.h" #include "base/strings/string_piece_forward.h"
namespace base { namespace base {
namespace fuchsia {
// Watches fuchsia.intl.PropertyProvider for change notifications and notifies // Watches fuchsia.intl.PropertyProvider for change notifications and notifies
// the provided callback. If necessary, the caller is responsible for // the provided callback. If necessary, the caller is responsible for
// determining whether an actual change of interest has occurred. // determining whether an actual change of interest has occurred.
class BASE_EXPORT IntlProfileWatcher { class BASE_EXPORT FuchsiaIntlProfileWatcher {
public: public:
using ProfileChangeCallback = using ProfileChangeCallback =
base::RepeatingCallback<void(const ::fuchsia::intl::Profile&)>; base::RepeatingCallback<void(const ::fuchsia::intl::Profile&)>;
// |on_profile_changed| will be called each time the profile may have changed. // |on_profile_changed| will be called each time the profile may have changed.
explicit IntlProfileWatcher(ProfileChangeCallback on_profile_changed); explicit FuchsiaIntlProfileWatcher(ProfileChangeCallback on_profile_changed);
IntlProfileWatcher(const IntlProfileWatcher&) = delete; FuchsiaIntlProfileWatcher(const FuchsiaIntlProfileWatcher&) = delete;
IntlProfileWatcher& operator=(const IntlProfileWatcher&) = delete; FuchsiaIntlProfileWatcher& operator=(const FuchsiaIntlProfileWatcher&) =
~IntlProfileWatcher(); delete;
~FuchsiaIntlProfileWatcher();
// Returns the ID of the primary time zone in |profile|. // Returns the ID of the primary time zone in |profile|.
// Returns the empty string if the ID cannot be obtained. // Returns the empty string if the ID cannot be obtained.
...@@ -45,7 +45,8 @@ class BASE_EXPORT IntlProfileWatcher { ...@@ -45,7 +45,8 @@ class BASE_EXPORT IntlProfileWatcher {
friend class GetPrimaryTimeZoneIdFromPropertyProviderTest; friend class GetPrimaryTimeZoneIdFromPropertyProviderTest;
friend class IntlProfileWatcherTest; friend class IntlProfileWatcherTest;
IntlProfileWatcher(::fuchsia::intl::PropertyProviderPtr property_provider, FuchsiaIntlProfileWatcher(
::fuchsia::intl::PropertyProviderPtr property_provider,
ProfileChangeCallback on_profile_changed); ProfileChangeCallback on_profile_changed);
// Returns the ID of the primary time zone from the profile obtained from // Returns the ID of the primary time zone from the profile obtained from
...@@ -57,7 +58,14 @@ class BASE_EXPORT IntlProfileWatcher { ...@@ -57,7 +58,14 @@ class BASE_EXPORT IntlProfileWatcher {
const ProfileChangeCallback on_profile_changed_; const ProfileChangeCallback on_profile_changed_;
}; };
// TODO(crbug.com/1073821): Remove this block when out-of-tree callers have been
// changed to use the non-fuchsia-sub-namespace version.
namespace fuchsia {
using IntlProfileWatcher = ::base::FuchsiaIntlProfileWatcher;
} // namespace fuchsia } // namespace fuchsia
} // namespace base } // namespace base
#endif // BASE_FUCHSIA_INTL_PROFILE_WATCHER_H_ #endif // BASE_FUCHSIA_INTL_PROFILE_WATCHER_H_
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
using ::fuchsia::intl::Profile; using ::fuchsia::intl::Profile;
namespace base { namespace base {
namespace fuchsia {
namespace { namespace {
...@@ -135,7 +134,7 @@ class GetPrimaryTimeZoneIdFromPropertyProviderTest : public testing::Test { ...@@ -135,7 +134,7 @@ class GetPrimaryTimeZoneIdFromPropertyProviderTest : public testing::Test {
protected: protected:
static std::string GetPrimaryTimeZoneIdFromPropertyProvider( static std::string GetPrimaryTimeZoneIdFromPropertyProvider(
::fuchsia::intl::PropertyProviderSyncPtr property_provider) { ::fuchsia::intl::PropertyProviderSyncPtr property_provider) {
return IntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider( return FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromPropertyProvider(
std::move(property_provider)); std::move(property_provider));
} }
...@@ -155,9 +154,9 @@ class IntlProfileWatcherTest : public testing::Test { ...@@ -155,9 +154,9 @@ class IntlProfileWatcherTest : public testing::Test {
base::test::SingleThreadTaskEnvironment task_environment_{ base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
std::unique_ptr<IntlProfileWatcher> CreateIntlProfileWatcher( std::unique_ptr<FuchsiaIntlProfileWatcher> CreateIntlProfileWatcher(
IntlProfileWatcher::ProfileChangeCallback on_profile_changed) { FuchsiaIntlProfileWatcher::ProfileChangeCallback on_profile_changed) {
return base::WrapUnique(new IntlProfileWatcher( return base::WrapUnique(new FuchsiaIntlProfileWatcher(
std::move(property_provider_ptr_), std::move(on_profile_changed))); std::move(property_provider_ptr_), std::move(on_profile_changed)));
} }
...@@ -169,15 +168,16 @@ class IntlProfileWatcherTest : public testing::Test { ...@@ -169,15 +168,16 @@ class IntlProfileWatcherTest : public testing::Test {
// Unit tests are run in an environment where intl is not provided. // Unit tests are run in an environment where intl is not provided.
// However, this is not exposed by the API. // However, this is not exposed by the API.
TEST(IntlServiceNotAvailableTest, IntlProfileWatcher) { TEST(IntlServiceNotAvailableTest, FuchsiaIntlProfileWatcher) {
base::test::SingleThreadTaskEnvironment task_environment_{ base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
base::RunLoop run_loop; base::RunLoop run_loop;
base::MockCallback<IntlProfileWatcher::ProfileChangeCallback> base::MockCallback<FuchsiaIntlProfileWatcher::ProfileChangeCallback>
on_profile_changed; on_profile_changed;
EXPECT_CALL(on_profile_changed, Run(testing::_)).Times(0); EXPECT_CALL(on_profile_changed, Run(testing::_)).Times(0);
auto watcher = std::make_unique<IntlProfileWatcher>(on_profile_changed.Get()); auto watcher =
std::make_unique<FuchsiaIntlProfileWatcher>(on_profile_changed.Get());
EXPECT_TRUE(watcher); EXPECT_TRUE(watcher);
run_loop.RunUntilIdle(); run_loop.RunUntilIdle();
...@@ -220,7 +220,7 @@ TEST_F(GetPrimaryTimeZoneIdFromPropertyProviderTest, MoreThanOneZone) { ...@@ -220,7 +220,7 @@ TEST_F(GetPrimaryTimeZoneIdFromPropertyProviderTest, MoreThanOneZone) {
} }
TEST_F(IntlProfileWatcherTest, NoZones_NoNotification) { TEST_F(IntlProfileWatcherTest, NoZones_NoNotification) {
base::MockCallback<IntlProfileWatcher::ProfileChangeCallback> callback; base::MockCallback<FuchsiaIntlProfileWatcher::ProfileChangeCallback> callback;
EXPECT_CALL(callback, Run(testing::_)).Times(0); EXPECT_CALL(callback, Run(testing::_)).Times(0);
auto watcher = CreateIntlProfileWatcher(callback.Get()); auto watcher = CreateIntlProfileWatcher(callback.Get());
run_loop_.RunUntilIdle(); run_loop_.RunUntilIdle();
...@@ -230,7 +230,8 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_AfterInitialization) { ...@@ -230,7 +230,8 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_AfterInitialization) {
auto watcher = CreateIntlProfileWatcher(base::BindLambdaForTesting( auto watcher = CreateIntlProfileWatcher(base::BindLambdaForTesting(
[quit_loop = run_loop_.QuitClosure()](const Profile& profile) { [quit_loop = run_loop_.QuitClosure()](const Profile& profile) {
EXPECT_EQ(kPrimaryTimeZoneName, EXPECT_EQ(kPrimaryTimeZoneName,
IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(profile)); FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
profile));
quit_loop.Run(); quit_loop.Run();
})); }));
...@@ -247,7 +248,8 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_BeforeInitialization) { ...@@ -247,7 +248,8 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_BeforeInitialization) {
auto watcher = CreateIntlProfileWatcher(base::BindLambdaForTesting( auto watcher = CreateIntlProfileWatcher(base::BindLambdaForTesting(
[quit_loop = run_loop_.QuitClosure()](const Profile& profile) { [quit_loop = run_loop_.QuitClosure()](const Profile& profile) {
EXPECT_EQ(kPrimaryTimeZoneName, EXPECT_EQ(kPrimaryTimeZoneName,
IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(profile)); FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
profile));
quit_loop.Run(); quit_loop.Run();
})); }));
...@@ -256,7 +258,7 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_BeforeInitialization) { ...@@ -256,7 +258,7 @@ TEST_F(IntlProfileWatcherTest, ChangeNotification_BeforeInitialization) {
// Ensure no crash when the peer service cannot be reached during creation. // Ensure no crash when the peer service cannot be reached during creation.
TEST_F(IntlProfileWatcherTest, ChannelClosedBeforeCreation) { TEST_F(IntlProfileWatcherTest, ChannelClosedBeforeCreation) {
base::MockCallback<IntlProfileWatcher::ProfileChangeCallback> callback; base::MockCallback<FuchsiaIntlProfileWatcher::ProfileChangeCallback> callback;
EXPECT_CALL(callback, Run(testing::_)).Times(0); EXPECT_CALL(callback, Run(testing::_)).Times(0);
property_provider_.Close(); property_provider_.Close();
...@@ -269,7 +271,7 @@ TEST_F(IntlProfileWatcherTest, ChannelClosedBeforeCreation) { ...@@ -269,7 +271,7 @@ TEST_F(IntlProfileWatcherTest, ChannelClosedBeforeCreation) {
// Ensure no crash when the channel is closed after creation. // Ensure no crash when the channel is closed after creation.
TEST_F(IntlProfileWatcherTest, ChannelClosedAfterCreation) { TEST_F(IntlProfileWatcherTest, ChannelClosedAfterCreation) {
base::MockCallback<IntlProfileWatcher::ProfileChangeCallback> callback; base::MockCallback<FuchsiaIntlProfileWatcher::ProfileChangeCallback> callback;
EXPECT_CALL(callback, Run(testing::_)).Times(0); EXPECT_CALL(callback, Run(testing::_)).Times(0);
auto watcher = CreateIntlProfileWatcher(callback.Get()); auto watcher = CreateIntlProfileWatcher(callback.Get());
...@@ -281,26 +283,26 @@ TEST_F(IntlProfileWatcherTest, ChannelClosedAfterCreation) { ...@@ -281,26 +283,26 @@ TEST_F(IntlProfileWatcherTest, ChannelClosedAfterCreation) {
} }
TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, NoZones) { TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, NoZones) {
EXPECT_EQ("", IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(Profile())); EXPECT_EQ("", FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
Profile()));
} }
TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, EmptyZonesList) { TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, EmptyZonesList) {
EXPECT_EQ("", IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile( EXPECT_EQ("", FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
CreateProfileWithTimeZones({}))); CreateProfileWithTimeZones({})));
} }
TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, OneZone) { TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, OneZone) {
EXPECT_EQ(kPrimaryTimeZoneName, EXPECT_EQ(kPrimaryTimeZoneName,
IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile( FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
CreateProfileWithTimeZones({kPrimaryTimeZoneName}))); CreateProfileWithTimeZones({kPrimaryTimeZoneName})));
} }
TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, TwoZones) { TEST(IntlProfileWatcherGetPrimaryTimeZoneIdFromProfileTest, TwoZones) {
EXPECT_EQ(kPrimaryTimeZoneName, EXPECT_EQ(kPrimaryTimeZoneName,
IntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile( FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdFromProfile(
CreateProfileWithTimeZones( CreateProfileWithTimeZones(
{kPrimaryTimeZoneName, kSecondaryTimeZoneName}))); {kPrimaryTimeZoneName, kSecondaryTimeZoneName})));
} }
} // namespace fuchsia
} // namespace base } // namespace base
...@@ -338,7 +338,7 @@ void InitializeIcuTimeZone() { ...@@ -338,7 +338,7 @@ void InitializeIcuTimeZone() {
// If the system time zone cannot be obtained or is not understood by ICU, // If the system time zone cannot be obtained or is not understood by ICU,
// the "unknown" time zone will be returned by createTimeZone() and used. // the "unknown" time zone will be returned by createTimeZone() and used.
std::string zone_id = std::string zone_id =
fuchsia::IntlProfileWatcher::GetPrimaryTimeZoneIdForIcuInitialization(); FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdForIcuInitialization();
icu::TimeZone::adoptDefault( icu::TimeZone::adoptDefault(
icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(zone_id))); icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(zone_id)));
#elif (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !BUILDFLAG(IS_CHROMECAST) #elif (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !BUILDFLAG(IS_CHROMECAST)
......
...@@ -48,7 +48,7 @@ class TimeZoneMonitorFuchsia : public TimeZoneMonitor { ...@@ -48,7 +48,7 @@ class TimeZoneMonitorFuchsia : public TimeZoneMonitor {
UpdateIcuAndNotifyClients(std::move(new_zone)); UpdateIcuAndNotifyClients(std::move(new_zone));
} }
base::fuchsia::IntlProfileWatcher watcher_; base::FuchsiaIntlProfileWatcher watcher_;
}; };
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment