Commit 8d3a19a3 authored by thestig's avatar thestig Committed by Commit bot

Fix static initializers in RlzValueStoreChromeOS.

BUG=537099

Review-Url: https://codereview.chromium.org/2800153002
Cr-Commit-Position: refs/heads/master@{#463004}
parent 406fa418
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/files/important_file_writer.h" #include "base/files/important_file_writer.h"
#include "base/json/json_file_value_serializer.h" #include "base/json/json_file_value_serializer.h"
#include "base/json/json_string_value_serializer.h" #include "base/json/json_string_value_serializer.h"
#include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -41,24 +42,25 @@ const base::FilePath::CharType kRLZLockFileName[] = ...@@ -41,24 +42,25 @@ const base::FilePath::CharType kRLZLockFileName[] =
FILE_PATH_LITERAL("RLZ Data.lock"); FILE_PATH_LITERAL("RLZ Data.lock");
// RLZ store path for testing. // RLZ store path for testing.
base::FilePath g_testing_rlz_store_path_; base::LazyInstance<base::FilePath>::Leaky g_testing_rlz_store_path =
LAZY_INSTANCE_INITIALIZER;
// Returns file path of the RLZ storage. base::FilePath GetRlzStorePathCommon() {
base::FilePath GetRlzStorePath() {
base::FilePath homedir; base::FilePath homedir;
PathService::Get(base::DIR_HOME, &homedir); PathService::Get(base::DIR_HOME, &homedir);
return g_testing_rlz_store_path_.empty() ? return g_testing_rlz_store_path.Get().empty()
homedir.Append(kRLZDataFileName) : ? homedir
g_testing_rlz_store_path_.Append(kRLZDataFileName); : g_testing_rlz_store_path.Get();
}
// Returns file path of the RLZ storage.
base::FilePath GetRlzStorePath() {
return GetRlzStorePathCommon().Append(kRLZDataFileName);
} }
// Returns file path of the RLZ storage lock file. // Returns file path of the RLZ storage lock file.
base::FilePath GetRlzStoreLockPath() { base::FilePath GetRlzStoreLockPath() {
base::FilePath homedir; return GetRlzStorePathCommon().Append(kRLZLockFileName);
PathService::Get(base::DIR_HOME, &homedir);
return g_testing_rlz_store_path_.empty() ?
homedir.Append(kRLZLockFileName) :
g_testing_rlz_store_path_.Append(kRLZLockFileName);
} }
// Returns the dictionary key for storing access point-related prefs. // Returns the dictionary key for storing access point-related prefs.
...@@ -155,7 +157,7 @@ bool RlzValueStoreChromeOS::ReadProductEvents( ...@@ -155,7 +157,7 @@ bool RlzValueStoreChromeOS::ReadProductEvents(
Product product, Product product,
std::vector<std::string>* events) { std::vector<std::string>* events) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
base::ListValue* events_list = NULL; ; base::ListValue* events_list = nullptr;
if (!rlz_store_->GetList(GetKeyName(kProductEventKey, product), &events_list)) if (!rlz_store_->GetList(GetKeyName(kProductEventKey, product), &events_list))
return false; return false;
events->clear(); events->clear();
...@@ -311,7 +313,7 @@ ScopedRlzValueStoreLock::ScopedRlzValueStoreLock() { ...@@ -311,7 +313,7 @@ ScopedRlzValueStoreLock::ScopedRlzValueStoreLock() {
ScopedRlzValueStoreLock::~ScopedRlzValueStoreLock() { ScopedRlzValueStoreLock::~ScopedRlzValueStoreLock() {
--g_lock_depth; --g_lock_depth;
DCHECK(g_lock_depth >= 0); DCHECK_GE(g_lock_depth, 0);
if (g_lock_depth > 0) { if (g_lock_depth > 0) {
// Other locks are still using store_, so don't free it yet. // Other locks are still using store_, so don't free it yet.
...@@ -331,7 +333,7 @@ RlzValueStore* ScopedRlzValueStoreLock::GetStore() { ...@@ -331,7 +333,7 @@ RlzValueStore* ScopedRlzValueStoreLock::GetStore() {
namespace testing { namespace testing {
void SetRlzStoreDirectory(const base::FilePath& directory) { void SetRlzStoreDirectory(const base::FilePath& directory) {
g_testing_rlz_store_path_ = directory; g_testing_rlz_store_path.Get() = directory;
} }
std::string RlzStoreFilenameStr() { std::string RlzStoreFilenameStr() {
......
...@@ -13,11 +13,10 @@ ...@@ -13,11 +13,10 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/non_thread_safe.h" #include "base/threading/non_thread_safe.h"
#include "base/values.h"
#include "rlz/lib/rlz_value_store.h" #include "rlz/lib/rlz_value_store.h"
namespace base { namespace base {
class SequencedTaskRunner; class DictionaryValue;
class Value; class Value;
} }
...@@ -27,12 +26,8 @@ namespace rlz_lib { ...@@ -27,12 +26,8 @@ namespace rlz_lib {
class RlzValueStoreChromeOS : public RlzValueStore, class RlzValueStoreChromeOS : public RlzValueStore,
public base::NonThreadSafe { public base::NonThreadSafe {
public: public:
// // Sets the task runner that will be used by ImportantFileWriter for write
// // operations.
// static void SetFileTaskRunner(base::SequencedTaskRunner* file_task_runner);
// Creates new instance and synchronously reads data from file. // Creates new instance and synchronously reads data from file.
RlzValueStoreChromeOS(const base::FilePath& store_path); explicit RlzValueStoreChromeOS(const base::FilePath& store_path);
~RlzValueStoreChromeOS() override; ~RlzValueStoreChromeOS() override;
// RlzValueStore overrides: // RlzValueStore overrides:
......
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