Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ mozc_cc_library(
visibility = [
"//:__subpackages__",
],
deps = [
"//base:singleton",
] + mozc_select(
deps = mozc_select(
android = [
":config_handler",
"//protocol:config_cc_proto",
Expand Down Expand Up @@ -152,13 +150,6 @@ mozc_cc_test(
),
)

mozc_cc_library(
name = "stats_config_util_mock",
testonly = True,
hdrs = ["stats_config_util_mock.h"],
deps = [":stats_config_util"],
)

mozc_cc_library(
name = "character_form_manager",
srcs = ["character_form_manager.cc"],
Expand Down
45 changes: 15 additions & 30 deletions src/config/stats_config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

#include "config/stats_config_util.h"

#include "base/singleton.h"

#ifdef _WIN32
#include <atlbase.h>
#include <lmcons.h>
Expand Down Expand Up @@ -80,10 +78,10 @@ constexpr wchar_t kOmahaUsageKeyForEveryone[] =

constexpr wchar_t kSendStatsName[] = L"usagestats";

class WinStatsConfigUtilImpl : public StatsConfigUtilInterface {
class WinStatsConfigUtilImpl {
public:
bool IsEnabled() override;
bool SetEnabled(bool val) override;
static bool IsEnabled();
static bool SetEnabled(bool val);
};

bool WinStatsConfigUtilImpl::IsEnabled() {
Expand Down Expand Up @@ -156,10 +154,10 @@ std::string GetConfigFilePath() {
"/.usagestats.db"); // hidden file
}

class MacStatsConfigUtilImpl : public StatsConfigUtilInterface {
class MacStatsConfigUtilImpl {
public:
bool IsEnabled() override;
bool SetEnabled(bool val) override;
static bool IsEnabled();
static bool SetEnabled(bool val);
};

bool MacStatsConfigUtilImpl::IsEnabled() {
Expand Down Expand Up @@ -216,12 +214,12 @@ bool MacStatsConfigUtilImpl::SetEnabled(bool val) {
#endif // MACOSX

#ifdef __ANDROID__
class AndroidStatsConfigUtilImpl : public StatsConfigUtilInterface {
class AndroidStatsConfigUtilImpl {
public:
bool IsEnabled() override {
static bool IsEnabled() {
return ConfigHandler::GetSharedConfig()->upload_usage_stats();
}
bool SetEnabled(bool val) override {
static bool SetEnabled(bool val) {
// TODO(horo): Implement this.
return false;
}
Expand All @@ -230,16 +228,12 @@ class AndroidStatsConfigUtilImpl : public StatsConfigUtilInterface {

#endif // GOOGLE_JAPANESE_INPUT_BUILD

class NullStatsConfigUtilImpl : public StatsConfigUtilInterface {
class NullStatsConfigUtilImpl {
public:
bool IsEnabled() override { return false; }
bool SetEnabled(bool val) override { return true; }
static bool IsEnabled() { return false; }
static bool SetEnabled(bool val) { return true; }
};

StatsConfigUtilInterface* g_stats_config_util_handler = nullptr;

// GetStatsConfigUtil and SetHandler are not thread safe.

#if !defined(GOOGLE_JAPANESE_INPUT_BUILD)
// For non-official build, use null implementation.
typedef NullStatsConfigUtilImpl DefaultConfigUtilImpl;
Expand All @@ -254,23 +248,14 @@ typedef AndroidStatsConfigUtilImpl DefaultConfigUtilImpl;
typedef NullStatsConfigUtilImpl DefaultConfigUtilImpl;
#endif // Platforms

StatsConfigUtilInterface& GetStatsConfigUtil() {
if (g_stats_config_util_handler == nullptr) {
return *(Singleton<DefaultConfigUtilImpl>::get());
} else {
return *g_stats_config_util_handler;
}
}
} // namespace

void StatsConfigUtil::SetHandler(StatsConfigUtilInterface* handler) {
g_stats_config_util_handler = handler;
bool StatsConfigUtil::IsEnabled() {
return DefaultConfigUtilImpl::IsEnabled();
}

bool StatsConfigUtil::IsEnabled() { return GetStatsConfigUtil().IsEnabled(); }

bool StatsConfigUtil::SetEnabled(bool val) {
return GetStatsConfigUtil().SetEnabled(val);
return DefaultConfigUtilImpl::SetEnabled(val);
}

} // namespace config
Expand Down
17 changes: 0 additions & 17 deletions src/config/stats_config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
namespace mozc {
namespace config {

// Interface class
class StatsConfigUtilInterface {
public:
StatsConfigUtilInterface() = default;
StatsConfigUtilInterface(const StatsConfigUtilInterface&) = delete;
StatsConfigUtilInterface& operator=(const StatsConfigUtilInterface&) = delete;
virtual ~StatsConfigUtilInterface() = default;

virtual bool IsEnabled() = 0;
virtual bool SetEnabled(bool val) = 0;
};

class StatsConfigUtil {
public:
StatsConfigUtil() = delete;
Expand All @@ -62,11 +50,6 @@ class StatsConfigUtil {
// Note: Administrative privilege is required in Windows.
// Returns true if succeeded.
static bool SetEnabled(bool val);

// Inject a dependency
static void SetHandler(StatsConfigUtilInterface* handler);

// Should never be allocated.
};

} // namespace config
Expand Down
56 changes: 0 additions & 56 deletions src/config/stats_config_util_mock.h

This file was deleted.