| Index: components/sync/base/weak_handle.h
|
| diff --git a/sync/internal_api/public/util/weak_handle.h b/components/sync/base/weak_handle.h
|
| similarity index 82%
|
| rename from sync/internal_api/public/util/weak_handle.h
|
| rename to components/sync/base/weak_handle.h
|
| index 2712c8a0cdb6deb9cc255d85f067a35935e92dbf..4dda6e921a659a4edfa61e52611081838fd78a78 100644
|
| --- a/sync/internal_api/public/util/weak_handle.h
|
| +++ b/components/sync/base/weak_handle.h
|
| @@ -44,8 +44,8 @@
|
| // void OnIOError(IOError err) { DCHECK(CalledOnValidThread(); ... }
|
| // };
|
|
|
| -#ifndef SYNC_INTERNAL_API_PUBLIC_UTIL_WEAK_HANDLE_H_
|
| -#define SYNC_INTERNAL_API_PUBLIC_UTIL_WEAK_HANDLE_H_
|
| +#ifndef COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_
|
| +#define COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_
|
|
|
| #include <cstddef>
|
| #include <utility>
|
| @@ -59,7 +59,7 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/single_thread_task_runner.h"
|
| -#include "sync/base/sync_export.h"
|
| +#include "components/sync/base/sync_export.h"
|
|
|
| namespace tracked_objects {
|
| class Location;
|
| @@ -67,7 +67,8 @@ class Location;
|
|
|
| namespace syncer {
|
|
|
| -template <typename T> class WeakHandle;
|
| +template <typename T>
|
| +class WeakHandle;
|
|
|
| namespace internal {
|
| // These classes are part of the WeakHandle implementation. DO NOT
|
| @@ -100,9 +101,8 @@ class SYNC_EXPORT WeakHandleCoreBase {
|
|
|
| // WeakHandleCore<T> contains all the logic for WeakHandle<T>.
|
| template <typename T>
|
| -class WeakHandleCore
|
| - : public WeakHandleCoreBase,
|
| - public base::RefCountedThreadSafe<WeakHandleCore<T> > {
|
| +class WeakHandleCore : public WeakHandleCoreBase,
|
| + public base::RefCountedThreadSafe<WeakHandleCore<T>> {
|
| public:
|
| // Must be called on |ptr|'s owner thread, which is assumed to be
|
| // the current thread.
|
| @@ -118,13 +118,14 @@ class WeakHandleCore
|
| // should be safe to be bound and copied across threads.
|
| template <typename Method, typename... Args>
|
| void Call(const tracked_objects::Location& from_here,
|
| - Method method, Args&&... args) const {
|
| - PostToOwnerThread(
|
| - from_here, base::Bind(method, ptr_, std::forward<Args>(args)...));
|
| + Method method,
|
| + Args&&... args) const {
|
| + PostToOwnerThread(from_here,
|
| + base::Bind(method, ptr_, std::forward<Args>(args)...));
|
| }
|
|
|
| private:
|
| - friend class base::RefCountedThreadSafe<WeakHandleCore<T> >;
|
| + friend class base::RefCountedThreadSafe<WeakHandleCore<T>>;
|
|
|
| // May be destroyed on any thread.
|
| ~WeakHandleCore() {}
|
| @@ -156,22 +157,17 @@ class WeakHandle {
|
| // that one can be called on any thread.
|
| template <typename U>
|
| WeakHandle(const WeakHandle<U>& other) // NOLINT
|
| - : core_(
|
| - other.IsInitialized() ?
|
| - new internal::WeakHandleCore<T>(other.Get()) :
|
| - NULL) {}
|
| + : core_(other.IsInitialized()
|
| + ? new internal::WeakHandleCore<T>(other.Get())
|
| + : NULL) {}
|
|
|
| // Returns true iff this WeakHandle is initialized. Note that being
|
| // initialized isn't a guarantee that the underlying object is still
|
| // alive.
|
| - bool IsInitialized() const {
|
| - return core_.get() != NULL;
|
| - }
|
| + bool IsInitialized() const { return core_.get() != NULL; }
|
|
|
| // Resets to an uninitialized WeakHandle.
|
| - void Reset() {
|
| - core_ = NULL;
|
| - }
|
| + void Reset() { core_ = NULL; }
|
|
|
| // Must be called only on the underlying object's owner thread.
|
| base::WeakPtr<T> Get() const {
|
| @@ -184,18 +180,17 @@ class WeakHandle {
|
| // should be safe to be bound and copied across threads.
|
| template <typename Method, typename... Args>
|
| void Call(const tracked_objects::Location& from_here,
|
| - Method method, Args&&... args) const {
|
| + Method method,
|
| + Args&&... args) const {
|
| CHECK(IsInitialized());
|
| core_->Call(from_here, method, std::forward<Args>(args)...);
|
| }
|
|
|
| private:
|
| - FRIEND_TEST_ALL_PREFIXES(WeakHandleTest,
|
| - TypeConversionConstructor);
|
| - FRIEND_TEST_ALL_PREFIXES(WeakHandleTest,
|
| - TypeConversionConstructorAssignment);
|
| + FRIEND_TEST_ALL_PREFIXES(WeakHandleTest, TypeConversionConstructor);
|
| + FRIEND_TEST_ALL_PREFIXES(WeakHandleTest, TypeConversionConstructorAssignment);
|
|
|
| - scoped_refptr<internal::WeakHandleCore<T> > core_;
|
| + scoped_refptr<internal::WeakHandleCore<T>> core_;
|
| };
|
|
|
| // Makes a WeakHandle from a WeakPtr.
|
| @@ -206,4 +201,4 @@ WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) {
|
|
|
| } // namespace syncer
|
|
|
| -#endif // SYNC_INTERNAL_API_PUBLIC_UTIL_WEAK_HANDLE_H_
|
| +#endif // COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_
|
|
|