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

Side by Side Diff: components/arc/instance_holder.h

Issue 2106663004: arc: Initial implemetation of Chrome sync for Arc packages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. More refactor. Fix unit_test related to refactor. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ARC_INSTANCE_HOLDER_H_ 5 #ifndef COMPONENTS_ARC_INSTANCE_HOLDER_H_
6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_ 6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 observer->OnInstanceReady(); 55 observer->OnInstanceReady();
56 } 56 }
57 57
58 void RemoveObserver(Observer* observer) { 58 void RemoveObserver(Observer* observer) {
59 DCHECK(thread_checker_.CalledOnValidThread()); 59 DCHECK(thread_checker_.CalledOnValidThread());
60 observer_list_.RemoveObserver(observer); 60 observer_list_.RemoveObserver(observer);
61 } 61 }
62 62
63 // Called when the channel is closed. 63 // Called when the channel is closed.
64 void CloseChannel() { 64 void CloseChannel() {
65 if (!ptr_) 65 if (!ptr_ && !raw_ptr_)
Luis Héctor Chávez 2016/07/20 00:01:15 Why is this needed?
lgcheng 2016/07/20 01:23:58 In test, ptr_ is never set. only raw_ptr_ is set.
66 return; 66 return;
67 67
68 ptr_.reset(); 68 ptr_.reset();
69 raw_ptr_ = nullptr; 69 raw_ptr_ = nullptr;
70 version_ = 0; 70 version_ = 0;
71 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstanceClosed()); 71 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstanceClosed());
72 } 72 }
73 73
74 // Sets the interface pointer to |ptr|, once the version is determined. This 74 // Sets the interface pointer to |ptr|, once the version is determined. This
75 // will eventually invoke SetInstance(), which will notify the observers. 75 // will eventually invoke SetInstance(), which will notify the observers.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // This needs to be the last member in order to cancel all inflight callbacks 118 // This needs to be the last member in order to cancel all inflight callbacks
119 // before destroying any other members. 119 // before destroying any other members.
120 base::WeakPtrFactory<InstanceHolder<T>> weak_factory_; 120 base::WeakPtrFactory<InstanceHolder<T>> weak_factory_;
121 121
122 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>); 122 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>);
123 }; 123 };
124 124
125 } // namespace arc 125 } // namespace arc
126 126
127 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_ 127 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_
OLDNEW
« components/arc/arc_bridge_service.cc ('K') | « components/arc/arc_bridge_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698