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

Side by Side Diff: content/browser/renderer_host/media/media_stream_device_settings.h

Issue 10829190: Resolve the problems where we can leak the system tray UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed testbots. Created 8 years, 4 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 | Annotate | Revision Log
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 // MediaStreamDeviceSettings is used to decide which of the available capture 5 // MediaStreamDeviceSettings is used to decide which of the available capture
6 // device to use as well as getting user permission to use the capture device. 6 // device to use as well as getting user permission to use the capture device.
7 // There will be one instance of MediaStreamDeviceSettings handling all 7 // There will be one instance of MediaStreamDeviceSettings handling all
8 // requests. 8 // requests.
9 9
10 // Expected call flow: 10 // Expected call flow:
11 // 1. RequestCaptureDeviceUsage() is called to create a new request for capture 11 // 1. RequestCaptureDeviceUsage() is called to create a new request for capture
12 // device usage. 12 // device usage.
13 // 2. AvailableDevices() is called with a list of currently available devices. 13 // 2. AvailableDevices() is called with a list of currently available devices.
14 // 3. Pick device and get user confirmation. 14 // 3. Pick device and get user confirmation.
15 // 4. Confirm by calling SettingsRequester::DevicesAccepted(). 15 // 4. Confirm by calling SettingsRequester::DevicesAccepted().
16 // Repeat step 1 - 4 for new device requests. 16 // Repeat step 1 - 4 for new device requests.
17 17
18 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_ 18 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_
19 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_ 19 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_
20 20
21 #include <map> 21 #include <map>
22 #include <string> 22 #include <string>
23 23
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "content/browser/renderer_host/media/media_stream_provider.h" 26 #include "content/browser/renderer_host/media/media_stream_provider.h"
27 27
28 namespace media_stream { 28 namespace media_stream {
29 29
30 class MediaStreamDeviceSettingsRequest;
31 class SettingsRequester; 30 class SettingsRequester;
31 struct MediaStreamDeviceSettingsRequest;
32 32
33 // MediaStreamDeviceSettings is responsible for getting user permission to use 33 // MediaStreamDeviceSettings is responsible for getting user permission to use
34 // a media capture device as well as selecting what device to use. 34 // a media capture device as well as selecting what device to use.
35 class CONTENT_EXPORT MediaStreamDeviceSettings { 35 class CONTENT_EXPORT MediaStreamDeviceSettings {
36 public: 36 public:
37 explicit MediaStreamDeviceSettings(SettingsRequester* requester); 37 explicit MediaStreamDeviceSettings(SettingsRequester* requester);
38 virtual ~MediaStreamDeviceSettings(); 38 virtual ~MediaStreamDeviceSettings();
39 39
40 // Called when a new request of capture device usage is made. 40 // Called when a new request of capture device usage is made.
41 void RequestCaptureDeviceUsage(const std::string& label, 41 void RequestCaptureDeviceUsage(const std::string& label,
(...skipping 23 matching lines...) Expand all
65 // needed for server based tests. The first non-opened device(s) will be 65 // needed for server based tests. The first non-opened device(s) will be
66 // picked. 66 // picked.
67 void UseFakeUI(); 67 void UseFakeUI();
68 68
69 private: 69 private:
70 typedef std::map<std::string, MediaStreamDeviceSettingsRequest*> 70 typedef std::map<std::string, MediaStreamDeviceSettingsRequest*>
71 SettingsRequests; 71 SettingsRequests;
72 72
73 // Returns true if the UI is already processing a request for this render 73 // Returns true if the UI is already processing a request for this render
74 // view. 74 // view.
75 bool IsUiBusy(int render_view_id, int render_process_id); 75 bool IsUIBusy(int render_view_id, int render_process_id);
76 76
77 // Finds a request ready to be sent to UI for user approval. 77 // Process the next pending request and bring it up to the UI on the given
78 std::string FindReadyRequestForView(int render_view_id, 78 // page for user approval.
79 int render_process_id); 79 void ProcessNextRequestForView(int render_view_id, int render_process_id);
80 80
81 // Posts a request to be approved/denied by UI. 81 // Posts a request to be approved/denied by UI.
82 void PostRequestToUi(const std::string& label); 82 void PostRequestToUI(const std::string& label);
83
84 // Posts a request to fake UI which is used for testing purpose.
85 void PostRequestToFakeUI(const std::string& label);
83 86
84 SettingsRequester* requester_; 87 SettingsRequester* requester_;
85 SettingsRequests requests_; 88 SettingsRequests requests_;
86 89
87 // See comment above for method UseFakeUI. Used for automated testing. 90 // See comment above for method UseFakeUI. Used for automated testing.
88 bool use_fake_ui_; 91 bool use_fake_ui_;
89 92
90 base::WeakPtrFactory<MediaStreamDeviceSettings> weak_ptr_factory_; 93 base::WeakPtrFactory<MediaStreamDeviceSettings> weak_ptr_factory_;
91 94
92 DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings); 95 DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings);
93 }; 96 };
94 97
95 } // namespace media_stream 98 } // namespace media_stream
96 99
97 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_ 100 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DEVICE_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698