Index: media/midi/midi_manager.h |
diff --git a/media/midi/midi_manager.h b/media/midi/midi_manager.h |
index 957c84d427f0dc85b291cd6b9cee188067dca5d7..8870fd999affc72a09b03cafdd845017fb270e2a 100644 |
--- a/media/midi/midi_manager.h |
+++ b/media/midi/midi_manager.h |
@@ -75,6 +75,10 @@ class MIDI_EXPORT MidiManager { |
// thread. |
static MidiManager* Create(); |
+ // Called on the CrBrowserMain thread to notify the Chrome_IOThread will stop |
+ // and the instance will be destructed on the CrBrowserMain thread soon. |
+ void Shutdown(); |
+ |
// A client calls StartSession() to receive and send MIDI data. |
// If the session is ready to start, the MIDI system is lazily initialized |
// and the client is registered to receive MIDI data. |
@@ -119,6 +123,12 @@ class MIDI_EXPORT MidiManager { |
// |result| should be Result::OK on success, otherwise a proper Result. |
virtual void StartInitialization(); |
+ // Finalizes the platform dependent MIDI system. Called on Chrome_IOThread |
+ // thread and the thread will stop immediately after this call. |
+ // Platform dependent resources that were allocated on the Chrome_IOThread |
+ // should be disposed inside this method. |
+ virtual void Finalize() {} |
+ |
// Called from a platform dependent implementation of StartInitialization(). |
// It invokes CompleteInitializationInternal() on the thread that calls |
// StartSession() and distributes |result| to MIDIManagerClient objects in |
@@ -154,6 +164,7 @@ class MIDI_EXPORT MidiManager { |
private: |
void CompleteInitializationInternal(Result result); |
void AddInitialPorts(MidiManagerClient* client); |
+ void ShutdownOnSessionThread(); |
// Keeps track of all clients who wish to receive MIDI data. |
typedef std::set<MidiManagerClient*> ClientSet; |
@@ -169,6 +180,9 @@ class MIDI_EXPORT MidiManager { |
// Keeps true if platform dependent initialization is already completed. |
bool initialized_; |
+ // Keeps false until Finalize() is called. |
+ bool finalized_; |
+ |
// Keeps the platform dependent initialization result if initialization is |
// completed. Otherwise keeps Result::NOT_INITIALIZED. |
Result result_; |
@@ -178,7 +192,7 @@ class MIDI_EXPORT MidiManager { |
MidiPortInfoList output_ports_; |
// Protects access to |clients_|, |pending_clients_|, |initialized_|, |
- // |result_|, |input_ports_| and |output_ports_|. |
+ // |finalize_|, |result_|, |input_ports_| and |output_ports_|. |
base::Lock lock_; |
DISALLOW_COPY_AND_ASSIGN(MidiManager); |