Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: components/sync/base/immutable.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/base/get_session_name_win.cc ('k') | components/sync/base/immutable_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « components/sync/base/get_session_name_win.cc ('k') | components/sync/base/immutable_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698