| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ |
| 6 #define COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ | 6 #define COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // } | 40 // } |
| 41 // | 41 // |
| 42 // void OnIOError(IOError err) { | 42 // void OnIOError(IOError err) { |
| 43 // foo_.Call(FROM_HERE, &Foo::OnIOError, err); | 43 // foo_.Call(FROM_HERE, &Foo::OnIOError, err); |
| 44 // } | 44 // } |
| 45 // | 45 // |
| 46 // private: | 46 // private: |
| 47 // const WeakHandle<Foo> foo_; | 47 // const WeakHandle<Foo> foo_; |
| 48 // }; | 48 // }; |
| 49 // | 49 // |
| 50 // class Foo : public SupportsWeakPtr<Foo>, public NonThreadSafe { | 50 // class Foo : public SupportsWeakPtr<Foo> { |
| 51 // public: | 51 // public: |
| 52 // Foo() { | 52 // Foo() { |
| 53 // SpawnFooIOWorkerOnIOThread(base::MakeWeakHandle(AsWeakPtr())); | 53 // SpawnFooIOWorkerOnIOThread(base::MakeWeakHandle(AsWeakPtr())); |
| 54 // } | 54 // } |
| 55 // | 55 // |
| 56 // /* Will always be called on the correct thread, and only if this | 56 // /* Will always be called on the correct thread, and only if this |
| 57 // object hasn't been destroyed. */ | 57 // object hasn't been destroyed. */ |
| 58 // void OnIOStart() { DCHECK(CalledOnValidThread(); ... } | 58 // void OnIOStart() { DCHECK(CalledOnValidThread(); ... } |
| 59 // void OnIOEvent(IOEvent e) { DCHECK(CalledOnValidThread(); ... } | 59 // void OnIOEvent(IOEvent e) { DCHECK(CalledOnValidThread(); ... } |
| 60 // void OnIOError(IOError err) { DCHECK(CalledOnValidThread(); ... } | 60 // void OnIOError(IOError err) { DCHECK(CalledOnValidThread(); ... } |
| 61 // |
| 62 // private: |
| 63 // SEQUENCE_CHECKER(sequence_checker_); |
| 61 // }; | 64 // }; |
| 62 | 65 |
| 63 namespace tracked_objects { | 66 namespace tracked_objects { |
| 64 class Location; | 67 class Location; |
| 65 } // namespace tracked_objects | 68 } // namespace tracked_objects |
| 66 | 69 |
| 67 namespace syncer { | 70 namespace syncer { |
| 68 | 71 |
| 69 template <typename T> | 72 template <typename T> |
| 70 class WeakHandle; | 73 class WeakHandle; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 197 |
| 195 // Makes a WeakHandle from a WeakPtr. | 198 // Makes a WeakHandle from a WeakPtr. |
| 196 template <typename T> | 199 template <typename T> |
| 197 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) { | 200 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) { |
| 198 return WeakHandle<T>(ptr); | 201 return WeakHandle<T>(ptr); |
| 199 } | 202 } |
| 200 | 203 |
| 201 } // namespace syncer | 204 } // namespace syncer |
| 202 | 205 |
| 203 #endif // COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ | 206 #endif // COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ |
| OLD | NEW |