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

Side by Side Diff: components/copresence/handlers/audio/audio_directive_handler_impl.cc

Issue 703433003: Checking that AudioDirectiveHandler::Initialize() gets called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h" 5 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 DCHECK(receives_lists_.empty()); 69 DCHECK(receives_lists_.empty());
70 receives_lists_.push_back(new AudioDirectiveList(clock_)); 70 receives_lists_.push_back(new AudioDirectiveList(clock_));
71 receives_lists_.push_back(new AudioDirectiveList(clock_)); 71 receives_lists_.push_back(new AudioDirectiveList(clock_));
72 } 72 }
73 73
74 void AudioDirectiveHandlerImpl::AddInstruction( 74 void AudioDirectiveHandlerImpl::AddInstruction(
75 const TokenInstruction& instruction, 75 const TokenInstruction& instruction,
76 const std::string& op_id, 76 const std::string& op_id,
77 base::TimeDelta ttl) { 77 base::TimeDelta ttl) {
78 DCHECK(transmits_lists_.size() == 2u && receives_lists_.size() == 2u)
79 << "Call Initialize() before other AudioDirectiveHandler methods";
80
78 switch (instruction.token_instruction_type()) { 81 switch (instruction.token_instruction_type()) {
79 case TRANSMIT: 82 case TRANSMIT:
80 DVLOG(2) << "Audio Transmit Directive received. Token: " 83 DVLOG(2) << "Audio Transmit Directive received. Token: "
81 << instruction.token_id() 84 << instruction.token_id()
82 << " with medium=" << instruction.medium() 85 << " with medium=" << instruction.medium()
83 << " with TTL=" << ttl.InMilliseconds(); 86 << " with TTL=" << ttl.InMilliseconds();
84 switch (instruction.medium()) { 87 switch (instruction.medium()) {
85 case AUDIO_ULTRASOUND_PASSBAND: 88 case AUDIO_ULTRASOUND_PASSBAND:
86 transmits_lists_[INAUDIBLE]->AddDirective(op_id, ttl); 89 transmits_lists_[INAUDIBLE]->AddDirective(op_id, ttl);
87 audio_manager_->SetToken(INAUDIBLE, instruction.token_id()); 90 audio_manager_->SetToken(INAUDIBLE, instruction.token_id());
(...skipping 23 matching lines...) Expand all
111 break; 114 break;
112 case UNKNOWN_TOKEN_INSTRUCTION_TYPE: 115 case UNKNOWN_TOKEN_INSTRUCTION_TYPE:
113 default: 116 default:
114 LOG(WARNING) << "Unknown Audio Transmit Directive received. type = " 117 LOG(WARNING) << "Unknown Audio Transmit Directive received. type = "
115 << instruction.token_instruction_type(); 118 << instruction.token_instruction_type();
116 } 119 }
117 ProcessNextInstruction(); 120 ProcessNextInstruction();
118 } 121 }
119 122
120 void AudioDirectiveHandlerImpl::RemoveInstructions(const std::string& op_id) { 123 void AudioDirectiveHandlerImpl::RemoveInstructions(const std::string& op_id) {
124 DCHECK(transmits_lists_.size() == 2u && receives_lists_.size() == 2u)
125 << "Call Initialize() before other AudioDirectiveHandler methods";
126
121 transmits_lists_[AUDIBLE]->RemoveDirective(op_id); 127 transmits_lists_[AUDIBLE]->RemoveDirective(op_id);
122 transmits_lists_[INAUDIBLE]->RemoveDirective(op_id); 128 transmits_lists_[INAUDIBLE]->RemoveDirective(op_id);
123 receives_lists_[AUDIBLE]->RemoveDirective(op_id); 129 receives_lists_[AUDIBLE]->RemoveDirective(op_id);
124 receives_lists_[INAUDIBLE]->RemoveDirective(op_id); 130 receives_lists_[INAUDIBLE]->RemoveDirective(op_id);
125 131
126 ProcessNextInstruction(); 132 ProcessNextInstruction();
127 } 133 }
128 134
129 const std::string AudioDirectiveHandlerImpl::PlayingToken( 135 const std::string AudioDirectiveHandlerImpl::PlayingToken(
130 AudioType type) const { 136 AudioType type) const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 184
179 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks()); 185 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks());
180 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry); 186 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry);
181 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry); 187 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry);
182 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry); 188 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry);
183 189
184 return !expiry->is_null(); 190 return !expiry->is_null();
185 } 191 }
186 192
187 } // namespace copresence 193 } // namespace copresence
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698