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

Unified Diff: media/midi/midi_manager.cc

Issue 662853003: Manage MIDI related objects and sessions' lifecycles correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittest 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 side-by-side diff with in-line comments
Download patch
Index: media/midi/midi_manager.cc
diff --git a/media/midi/midi_manager.cc b/media/midi/midi_manager.cc
index c53eef4112c33a662bd5e850e38c497df8c52aaf..fbccbba28712bb4120f5c6cee99a3fd4068a5408 100644
--- a/media/midi/midi_manager.cc
+++ b/media/midi/midi_manager.cc
@@ -26,7 +26,7 @@ MidiManager* MidiManager::Create() {
}
#endif
-void MidiManager::StartSession(MidiManagerClient* client, int client_id) {
+void MidiManager::StartSession(MidiManagerClient* client) {
bool session_is_ready;
bool session_needs_initialization = false;
bool too_many_pending_clients_exist = false;
@@ -43,7 +43,7 @@ void MidiManager::StartSession(MidiManagerClient* client, int client_id) {
if (!too_many_pending_clients_exist) {
// Call StartInitialization() only for the first request.
session_needs_initialization = pending_clients_.empty();
- pending_clients_.insert(std::make_pair(client, client_id));
+ pending_clients_.insert(client);
}
}
}
@@ -58,7 +58,7 @@ void MidiManager::StartSession(MidiManagerClient* client, int client_id) {
}
if (too_many_pending_clients_exist) {
// Return an error immediately if there are too many requests.
- client->CompleteStartSession(client_id, MIDI_INITIALIZATION_ERROR);
+ client->CompleteStartSession(MIDI_INITIALIZATION_ERROR);
return;
}
// CompleteInitialization() will be called asynchronously when platform
@@ -75,7 +75,7 @@ void MidiManager::StartSession(MidiManagerClient* client, int client_id) {
clients_.insert(client);
result = result_;
}
- client->CompleteStartSession(client_id, result);
+ client->CompleteStartSession(result);
}
void MidiManager::EndSession(MidiManagerClient* client) {
@@ -121,8 +121,8 @@ void MidiManager::ReceiveMidiData(
double timestamp) {
base::AutoLock auto_lock(lock_);
- for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i)
- (*i)->ReceiveMidiData(port_index, data, length, timestamp);
+ for (ClientSet::iterator it = clients_.begin(); it != clients_.end(); ++it)
yhirano 2014/10/20 12:15:15 You can use the range-based for.
Takashi Toyoshima 2014/10/20 17:14:44 Done.
+ (*it)->ReceiveMidiData(port_index, data, length, timestamp);
}
void MidiManager::CompleteInitializationInternal(MidiResult result) {
@@ -134,12 +134,12 @@ void MidiManager::CompleteInitializationInternal(MidiResult result) {
initialized_ = true;
result_ = result;
- for (PendingClientMap::iterator it = pending_clients_.begin();
+ for (ClientSet::iterator it = pending_clients_.begin();
yhirano 2014/10/20 12:15:15 ditto
Takashi Toyoshima 2014/10/20 17:14:44 Done.
it != pending_clients_.end();
++it) {
if (result_ == MIDI_OK)
- clients_.insert(it->first);
- it->first->CompleteStartSession(it->second, result_);
+ clients_.insert(*it);
+ (*it)->CompleteStartSession(result_);
}
pending_clients_.clear();
}

Powered by Google App Engine
This is Rietveld 408576698