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

Side by Side Diff: components/copresence/handlers/audio/audio_directive_list.h

Issue 670623002: Change base::TickClock to a ref counted class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_redesign
Patch Set: y Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_ 5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_
6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_ 6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 16
16 namespace base { 17 namespace base {
17 class TickClock; 18 class TickClock;
18 } 19 }
19 20
20 namespace media { 21 namespace media {
21 class AudioBusRefCounted; 22 class AudioBusRefCounted;
22 } 23 }
(...skipping 18 matching lines...) Expand all
41 class AudioDirectiveList { 42 class AudioDirectiveList {
42 public: 43 public:
43 AudioDirectiveList(); 44 AudioDirectiveList();
44 ~AudioDirectiveList(); 45 ~AudioDirectiveList();
45 46
46 void AddDirective(const std::string& op_id, base::TimeDelta ttl); 47 void AddDirective(const std::string& op_id, base::TimeDelta ttl);
47 void RemoveDirective(const std::string& op_id); 48 void RemoveDirective(const std::string& op_id);
48 49
49 scoped_ptr<AudioDirective> GetActiveDirective(); 50 scoped_ptr<AudioDirective> GetActiveDirective();
50 51
52 void set_clock_for_testing(const scoped_refptr<base::TickClock>& clock);
53
51 private: 54 private:
52 // Comparator for comparing end_times on audio tokens. 55 // Comparator for comparing end_times on audio tokens.
53 class LatestFirstComparator { 56 class LatestFirstComparator {
54 public: 57 public:
55 // This will sort our queue with the 'latest' time being the top. 58 // This will sort our queue with the 'latest' time being the top.
56 bool operator()(const AudioDirective& left, 59 bool operator()(const AudioDirective& left,
57 const AudioDirective& right) const { 60 const AudioDirective& right) const {
58 return left.end_time < right.end_time; 61 return left.end_time < right.end_time;
59 } 62 }
60 }; 63 };
61 64
62 std::vector<AudioDirective>::iterator FindDirectiveByOpId( 65 std::vector<AudioDirective>::iterator FindDirectiveByOpId(
63 const std::string& op_id); 66 const std::string& op_id);
64 67
65 // This vector will be organized as a heap with the latest time as the first 68 // This vector will be organized as a heap with the latest time as the first
66 // element. Only currently active directives will exist in this list. 69 // element. Only currently active directives will exist in this list.
67 std::vector<AudioDirective> active_directives_; 70 std::vector<AudioDirective> active_directives_;
68 71
69 scoped_ptr<base::TickClock> clock_; 72 scoped_refptr<base::TickClock> clock_;
70 73
71 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveList); 74 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveList);
72 }; 75 };
73 76
74 } // namespace copresence 77 } // namespace copresence
75 78
76 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_ 79 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698