Skip to content

Commit

Permalink
Move base/prefs to components/prefs
Browse files Browse the repository at this point in the history
This change is the minimal move change. It does not update namespaces or includes. Forwarding headers and targets exist to map to the new location. The namespaces, include guards, and references to these files will be updated in follow-ups.

The GYP build has been updated to point to the new location because the forwarding headers generated a .gyp file cycle. Avoiding a cycle with libaddressinput is why prefs is a separate .gyp from most of the rest of the components. The GN build uses forwarding targets to keep the change smaller.

The json pref store unit tests had to be updated because of the way that they used histograms conflicted with the hsitogram setup of the components unittests. Fortunately, there's a HistogramTester helper for this case, so this patch uses it in for the moved test in place of manually checking histogram counts.

json_pref_store_unittests.cc also depended on the files il base/test/data/prefs. Rather than worry about updating all the isolates and such, this just adds the data inline and avoids having separate test files.

BUG=

Review URL: https://codereview.chromium.org/1648403002

Cr-Commit-Position: refs/heads/master@{#372494}
  • Loading branch information
brettw authored and Commit bot committed Jan 30, 2016
1 parent 40f86a8 commit deb824c
Show file tree
Hide file tree
Showing 125 changed files with 3,225 additions and 3,026 deletions.
91 changes: 7 additions & 84 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1465,82 +1465,17 @@ if (is_ios || is_android || is_win || (is_linux && !is_chromeos)) {
}
}

component("prefs") {
sources = [
"prefs/default_pref_store.cc",
"prefs/default_pref_store.h",
"prefs/json_pref_store.cc",
"prefs/json_pref_store.h",
"prefs/overlay_user_pref_store.cc",
"prefs/overlay_user_pref_store.h",
"prefs/pref_change_registrar.cc",
"prefs/pref_change_registrar.h",
"prefs/pref_member.cc",
"prefs/pref_member.h",
"prefs/pref_notifier_impl.cc",
"prefs/pref_notifier_impl.h",
"prefs/pref_registry.cc",
"prefs/pref_registry.h",
"prefs/pref_registry_simple.cc",
"prefs/pref_registry_simple.h",
"prefs/pref_service.cc",
"prefs/pref_service.h",
"prefs/pref_service_factory.cc",
"prefs/pref_service_factory.h",
"prefs/pref_store.cc",
"prefs/pref_store.h",
"prefs/pref_value_map.cc",
"prefs/pref_value_map.h",
"prefs/pref_value_store.cc",
"prefs/pref_value_store.h",
"prefs/scoped_user_pref_update.cc",
"prefs/scoped_user_pref_update.h",
"prefs/value_map_pref_store.cc",
"prefs/value_map_pref_store.h",
]
if (!is_ios) {
sources += [
"prefs/base_prefs_export.h",
"prefs/persistent_pref_store.h",
"prefs/pref_filter.h",
"prefs/pref_notifier.h",
"prefs/pref_observer.h",
"prefs/writeable_pref_store.h",
]
}

defines = [ "BASE_PREFS_IMPLEMENTATION" ]

deps = [
":base",
# TODO(brettw) remove these forwarding targets when all references to prefs are
# updated to point to components.
group("prefs") {
public_deps = [
"//components/prefs",
]

if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}

source_set("prefs_test_support") {
group("prefs_test_support") {
testonly = true
sources = [
"prefs/mock_pref_change_callback.cc",
"prefs/mock_pref_change_callback.h",
"prefs/pref_store_observer_mock.cc",
"prefs/pref_store_observer_mock.h",
"prefs/testing_pref_service.cc",
"prefs/testing_pref_service.h",
"prefs/testing_pref_store.cc",
"prefs/testing_pref_store.h",
]

public_deps = [
":prefs",
]
deps = [
":base",
"//testing/gmock",
"//testing/gtest",
"//components/prefs:test_support",
]
}

Expand Down Expand Up @@ -1731,16 +1666,6 @@ test("base_unittests") {
"posix/file_descriptor_shuffle_unittest.cc",
"posix/unix_domain_socket_linux_unittest.cc",
"power_monitor/power_monitor_unittest.cc",
"prefs/default_pref_store_unittest.cc",
"prefs/json_pref_store_unittest.cc",
"prefs/overlay_user_pref_store_unittest.cc",
"prefs/pref_change_registrar_unittest.cc",
"prefs/pref_member_unittest.cc",
"prefs/pref_notifier_impl_unittest.cc",
"prefs/pref_service_unittest.cc",
"prefs/pref_value_map_unittest.cc",
"prefs/pref_value_store_unittest.cc",
"prefs/scoped_user_pref_update_unittest.cc",
"process/memory_unittest.cc",
"process/memory_unittest_mac.h",
"process/memory_unittest_mac.mm",
Expand Down Expand Up @@ -1860,8 +1785,6 @@ test("base_unittests") {
":base",
":i18n",
":message_loop_tests",
":prefs",
":prefs_test_support",
"//base/test:run_all_unittests",
"//base/test:test_support",
"//base/third_party/dynamic_annotations",
Expand Down
89 changes: 0 additions & 89 deletions base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -311,82 +311,6 @@
'message_loop/message_loop_test.h',
],
},
{
'target_name': 'base_prefs',
'type': '<(component)',
'variables': {
'enable_wexit_time_destructors': 1,
'optimize': 'max',
},
'dependencies': [
'base',
],
'export_dependent_settings': [
'base',
],
'defines': [
'BASE_PREFS_IMPLEMENTATION',
],
'sources': [
'prefs/base_prefs_export.h',
'prefs/default_pref_store.cc',
'prefs/default_pref_store.h',
'prefs/json_pref_store.cc',
'prefs/json_pref_store.h',
'prefs/overlay_user_pref_store.cc',
'prefs/overlay_user_pref_store.h',
'prefs/persistent_pref_store.h',
'prefs/pref_change_registrar.cc',
'prefs/pref_change_registrar.h',
'prefs/pref_filter.h',
'prefs/pref_member.cc',
'prefs/pref_member.h',
'prefs/pref_notifier.h',
'prefs/pref_notifier_impl.cc',
'prefs/pref_notifier_impl.h',
'prefs/pref_observer.h',
'prefs/pref_registry.cc',
'prefs/pref_registry.h',
'prefs/pref_registry_simple.cc',
'prefs/pref_registry_simple.h',
'prefs/pref_service.cc',
'prefs/pref_service.h',
'prefs/pref_service_factory.cc',
'prefs/pref_service_factory.h',
'prefs/pref_store.cc',
'prefs/pref_store.h',
'prefs/pref_value_map.cc',
'prefs/pref_value_map.h',
'prefs/pref_value_store.cc',
'prefs/pref_value_store.h',
'prefs/scoped_user_pref_update.cc',
'prefs/scoped_user_pref_update.h',
'prefs/value_map_pref_store.cc',
'prefs/value_map_pref_store.h',
'prefs/writeable_pref_store.h',
],
'includes': [
'../build/android/increase_size_for_speed.gypi',
],
},
{
'target_name': 'base_prefs_test_support',
'type': 'static_library',
'dependencies': [
'base',
'base_prefs',
'../testing/gmock.gyp:gmock',
],
'sources': [
'prefs/mock_pref_change_callback.cc',
'prefs/pref_store_observer_mock.cc',
'prefs/pref_store_observer_mock.h',
'prefs/testing_pref_service.cc',
'prefs/testing_pref_service.h',
'prefs/testing_pref_store.cc',
'prefs/testing_pref_store.h',
],
},
{
# This is the subset of files from base that should not be used with a
# dynamic library. Note that this library cannot depend on base because
Expand Down Expand Up @@ -566,17 +490,6 @@
'posix/file_descriptor_shuffle_unittest.cc',
'posix/unix_domain_socket_linux_unittest.cc',
'power_monitor/power_monitor_unittest.cc',
'prefs/default_pref_store_unittest.cc',
'prefs/json_pref_store_unittest.cc',
'prefs/mock_pref_change_callback.h',
'prefs/overlay_user_pref_store_unittest.cc',
'prefs/pref_change_registrar_unittest.cc',
'prefs/pref_member_unittest.cc',
'prefs/pref_notifier_impl_unittest.cc',
'prefs/pref_service_unittest.cc',
'prefs/pref_value_map_unittest.cc',
'prefs/pref_value_store_unittest.cc',
'prefs/scoped_user_pref_update_unittest.cc',
'process/memory_unittest.cc',
'process/memory_unittest_mac.h',
'process/memory_unittest_mac.mm',
Expand Down Expand Up @@ -678,8 +591,6 @@
'base',
'base_i18n',
'base_message_loop_tests',
'base_prefs',
'base_prefs_test_support',
'base_static',
'run_all_unittests',
'test_support_base',
Expand Down
4 changes: 4 additions & 0 deletions base/prefs/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TODO(brettw) remove this when prefs is completely moved to components.
include_rules = [
"+components/prefs",
]
6 changes: 0 additions & 6 deletions base/prefs/README

This file was deleted.

28 changes: 3 additions & 25 deletions base/prefs/base_prefs_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_PREFS_BASE_PREFS_EXPORT_H_
#define BASE_PREFS_BASE_PREFS_EXPORT_H_

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(BASE_PREFS_IMPLEMENTATION)
#define BASE_PREFS_EXPORT __declspec(dllexport)
#else
#define BASE_PREFS_EXPORT __declspec(dllimport)
#endif // defined(BASE_PREFS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(BASE_PREFS_IMPLEMENTATION)
#define BASE_PREFS_EXPORT __attribute__((visibility("default")))
#else
#define BASE_PREFS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
#define BASE_PREFS_EXPORT
#endif

#endif // BASE_PREFS_BASE_PREFS_EXPORT_H_
// TODO(brettw) remove this forwarding header when prefs is completely moved to
// components.
#include "components/prefs/base_prefs_export.h"
52 changes: 3 additions & 49 deletions base/prefs/default_pref_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_PREFS_DEFAULT_PREF_STORE_H_
#define BASE_PREFS_DEFAULT_PREF_STORE_H_

#include <string>

#include "base/macros.h"
#include "base/observer_list.h"
#include "base/prefs/base_prefs_export.h"
#include "base/prefs/pref_store.h"
#include "base/prefs/pref_value_map.h"
#include "base/values.h"

// Used within a PrefRegistry to keep track of default preference values.
class BASE_PREFS_EXPORT DefaultPrefStore : public PrefStore {
public:
typedef PrefValueMap::const_iterator const_iterator;

DefaultPrefStore();

// PrefStore implementation:
bool GetValue(const std::string& key,
const base::Value** result) const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;

// Sets a |value| for |key|. Should only be called if a value has not been
// set yet; otherwise call ReplaceDefaultValue().
void SetDefaultValue(const std::string& key, scoped_ptr<base::Value> value);

// Replaces the the value for |key| with a new value. Should only be called
// if a value has alreday been set; otherwise call SetDefaultValue().
void ReplaceDefaultValue(const std::string& key,
scoped_ptr<base::Value> value);

const_iterator begin() const;
const_iterator end() const;

private:
~DefaultPrefStore() override;

PrefValueMap prefs_;

base::ObserverList<PrefStore::Observer, true> observers_;

DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore);
};

#endif // BASE_PREFS_DEFAULT_PREF_STORE_H_
// TODO(brettw) remove this forwarding header when prefs is completely moved to
// components.
#include "components/prefs/default_pref_store.h"
Loading

0 comments on commit deb824c

Please sign in to comment.