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

Side by Side Diff: base/scoped_observer.h

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « base/profiler/tracked_time_unittest.cc ('k') | base/sequence_checker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 BASE_SCOPED_OBSERVER_H_ 5 #ifndef BASE_SCOPED_OBSERVER_H_
6 #define BASE_SCOPED_OBSERVER_H_ 6 #define BASE_SCOPED_OBSERVER_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 30 matching lines...) Expand all
41 for (size_t i = 0; i < sources_.size(); ++i) 41 for (size_t i = 0; i < sources_.size(); ++i)
42 sources_[i]->RemoveObserver(observer_); 42 sources_[i]->RemoveObserver(observer_);
43 sources_.clear(); 43 sources_.clear();
44 } 44 }
45 45
46 bool IsObserving(Source* source) const { 46 bool IsObserving(Source* source) const {
47 return std::find(sources_.begin(), sources_.end(), source) != 47 return std::find(sources_.begin(), sources_.end(), source) !=
48 sources_.end(); 48 sources_.end();
49 } 49 }
50 50
51 bool IsObservingSources() const { return !sources_.empty(); }
52
51 private: 53 private:
52 Observer* observer_; 54 Observer* observer_;
53 55
54 std::vector<Source*> sources_; 56 std::vector<Source*> sources_;
55 57
56 DISALLOW_COPY_AND_ASSIGN(ScopedObserver); 58 DISALLOW_COPY_AND_ASSIGN(ScopedObserver);
57 }; 59 };
58 60
59 #endif // BASE_SCOPED_OBSERVER_H_ 61 #endif // BASE_SCOPED_OBSERVER_H_
OLDNEW
« no previous file with comments | « base/profiler/tracked_time_unittest.cc ('k') | base/sequence_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698