| Index: components/sync/base/immutable.h
|
| diff --git a/sync/internal_api/public/util/immutable.h b/components/sync/base/immutable.h
|
| similarity index 91%
|
| rename from sync/internal_api/public/util/immutable.h
|
| rename to components/sync/base/immutable.h
|
| index d432f9fa9a382c794b410c142ee750325f392137..21d0b4f8ecd6595af652f0d4163f63bd3f8be3e4 100644
|
| --- a/sync/internal_api/public/util/immutable.h
|
| +++ b/components/sync/base/immutable.h
|
| @@ -61,8 +61,8 @@
|
| // with forward-declared types. See comments on traits below for
|
| // details.
|
|
|
| -#ifndef SYNC_INTERNAL_API_PUBLIC_UTIL_IMMUTABLE_H_
|
| -#define SYNC_INTERNAL_API_PUBLIC_UTIL_IMMUTABLE_H_
|
| +#ifndef COMPONENTS_SYNC_BASE_IMMUTABLE_H_
|
| +#define COMPONENTS_SYNC_BASE_IMMUTABLE_H_
|
|
|
| // For std::swap().
|
| #include <algorithm>
|
| @@ -78,30 +78,24 @@ namespace internal {
|
|
|
| template <typename T, typename Traits>
|
| class ImmutableCore
|
| - : public base::RefCountedThreadSafe<ImmutableCore<T, Traits> > {
|
| + : public base::RefCountedThreadSafe<ImmutableCore<T, Traits>> {
|
| public:
|
| // wrapper_ is always explicitly default-initialized to handle
|
| // primitive types and the case where Traits::Wrapper == T.
|
|
|
| - ImmutableCore() : wrapper_() {
|
| - Traits::InitializeWrapper(&wrapper_);
|
| - }
|
| + ImmutableCore() : wrapper_() { Traits::InitializeWrapper(&wrapper_); }
|
|
|
| explicit ImmutableCore(T* t) : wrapper_() {
|
| Traits::InitializeWrapper(&wrapper_);
|
| Traits::Swap(Traits::UnwrapMutable(&wrapper_), t);
|
| }
|
|
|
| - const T& Get() const {
|
| - return Traits::Unwrap(wrapper_);
|
| - }
|
| + const T& Get() const { return Traits::Unwrap(wrapper_); }
|
|
|
| private:
|
| friend class base::RefCountedThreadSafe<ImmutableCore<T, Traits>>;
|
|
|
| - ~ImmutableCore() {
|
| - Traits::DestroyWrapper(&wrapper_);
|
| - }
|
| + ~ImmutableCore() { Traits::DestroyWrapper(&wrapper_); }
|
|
|
| // This is semantically const, but we can't mark it a such as we
|
| // modify it in the constructor.
|
| @@ -216,21 +210,17 @@ struct DefaultImmutableTraits {
|
| // although they usually already overload std::swap() to use those.
|
| template <typename T>
|
| struct HasSwapMemFnByRef : public DefaultImmutableTraits<T> {
|
| - static void Swap(T* t1, T* t2) {
|
| - t1->swap(*t2);
|
| - }
|
| + static void Swap(T* t1, T* t2) { t1->swap(*t2); }
|
| };
|
|
|
| // Most Google-style objects have by-pointer Swap() member functions
|
| // (for example, generated protocol buffer classes).
|
| template <typename T>
|
| struct HasSwapMemFnByPtr : public DefaultImmutableTraits<T> {
|
| - static void Swap(T* t1, T* t2) {
|
| - t1->Swap(t2);
|
| - }
|
| + static void Swap(T* t1, T* t2) { t1->Swap(t2); }
|
| };
|
|
|
| -template <typename T, typename Traits = DefaultImmutableTraits<T> >
|
| +template <typename T, typename Traits = DefaultImmutableTraits<T>>
|
| class Immutable {
|
| public:
|
| // Puts the underlying object in a default-initialized state.
|
| @@ -239,15 +229,12 @@ class Immutable {
|
| // Copy constructor and assignment welcome.
|
|
|
| // Resets |t| to a default-initialized state.
|
| - explicit Immutable(T* t)
|
| - : core_(new internal::ImmutableCore<T, Traits>(t)) {}
|
| + explicit Immutable(T* t) : core_(new internal::ImmutableCore<T, Traits>(t)) {}
|
|
|
| - const T& Get() const {
|
| - return core_->Get();
|
| - }
|
| + const T& Get() const { return core_->Get(); }
|
|
|
| private:
|
| - scoped_refptr<const internal::ImmutableCore<T, Traits> > core_;
|
| + scoped_refptr<const internal::ImmutableCore<T, Traits>> core_;
|
| };
|
|
|
| // Helper function to avoid having to write out template arguments.
|
| @@ -258,4 +245,4 @@ Immutable<T> MakeImmutable(T* t) {
|
|
|
| } // namespace syncer
|
|
|
| -#endif // SYNC_INTERNAL_API_PUBLIC_UTIL_IMMUTABLE_H_
|
| +#endif // COMPONENTS_SYNC_BASE_IMMUTABLE_H_
|
|
|