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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_input.h

Issue 2882133002: Block insecure pepper media requests in the renderer (Closed)
Patch Set: Block insecure pepper media requests Created 3 years, 7 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 (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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "media/audio/audio_input_ipc.h" 15 #include "media/audio/audio_input_ipc.h"
16 #include "media/base/audio_parameters.h" 16 #include "media/base/audio_parameters.h"
17 17
18 class GURL;
19
20 namespace base { 18 namespace base {
21 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
22 } 20 }
23 21
24 namespace media { 22 namespace media {
25 class AudioParameters; 23 class AudioParameters;
26 } 24 }
27 25
28 namespace content { 26 namespace content {
29 27
30 class PepperAudioInputHost; 28 class PepperAudioInputHost;
31 class PepperMediaDeviceManager; 29 class PepperMediaDeviceManager;
32 30
33 // PepperPlatformAudioInput is operated on two threads: the main thread (the 31 // PepperPlatformAudioInput is operated on two threads: the main thread (the
34 // thread on which objects are created) and the I/O thread. All public methods, 32 // thread on which objects are created) and the I/O thread. All public methods,
35 // except the destructor, must be called on the main thread. The notifications 33 // except the destructor, must be called on the main thread. The notifications
36 // to the users of this class (i.e. PepperAudioInputHost) are also sent on the 34 // to the users of this class (i.e. PepperAudioInputHost) are also sent on the
37 // main thread. Internally, this class sends audio input IPC messages and 35 // main thread. Internally, this class sends audio input IPC messages and
38 // receives media::AudioInputIPCDelegate notifications on the I/O thread. 36 // receives media::AudioInputIPCDelegate notifications on the I/O thread.
39 37
40 class PepperPlatformAudioInput 38 class PepperPlatformAudioInput
41 : public media::AudioInputIPCDelegate, 39 : public media::AudioInputIPCDelegate,
42 public base::RefCountedThreadSafe<PepperPlatformAudioInput> { 40 public base::RefCountedThreadSafe<PepperPlatformAudioInput> {
43 public: 41 public:
44 // Factory function, returns NULL on failure. StreamCreated() will be called 42 // Factory function, returns NULL on failure. StreamCreated() will be called
45 // when the stream is created. 43 // when the stream is created.
46 static PepperPlatformAudioInput* Create( 44 static PepperPlatformAudioInput* Create(
47 int render_frame_id, 45 int render_frame_id,
48 const std::string& device_id, 46 const std::string& device_id,
49 const GURL& document_url,
50 int sample_rate, 47 int sample_rate,
51 int frames_per_buffer, 48 int frames_per_buffer,
52 PepperAudioInputHost* client); 49 PepperAudioInputHost* client);
53 50
54 // Called on main thread. 51 // Called on main thread.
55 void StartCapture(); 52 void StartCapture();
56 void StopCapture(); 53 void StopCapture();
57 // Closes the stream. Make sure to call this before the object is destructed. 54 // Closes the stream. Make sure to call this before the object is destructed.
58 void ShutDown(); 55 void ShutDown();
59 56
60 // media::AudioInputIPCDelegate. 57 // media::AudioInputIPCDelegate.
61 void OnStreamCreated(base::SharedMemoryHandle handle, 58 void OnStreamCreated(base::SharedMemoryHandle handle,
62 base::SyncSocket::Handle socket_handle, 59 base::SyncSocket::Handle socket_handle,
63 int length, 60 int length,
64 int total_segments) override; 61 int total_segments) override;
65 void OnError() override; 62 void OnError() override;
66 void OnIPCClosed() override; 63 void OnIPCClosed() override;
67 64
68 protected: 65 protected:
69 ~PepperPlatformAudioInput() override; 66 ~PepperPlatformAudioInput() override;
70 67
71 private: 68 private:
72 friend class base::RefCountedThreadSafe<PepperPlatformAudioInput>; 69 friend class base::RefCountedThreadSafe<PepperPlatformAudioInput>;
73 70
74 PepperPlatformAudioInput(); 71 PepperPlatformAudioInput();
75 72
76 bool Initialize(int render_frame_id, 73 bool Initialize(int render_frame_id,
77 const std::string& device_id, 74 const std::string& device_id,
78 const GURL& document_url,
79 int sample_rate, 75 int sample_rate,
80 int frames_per_buffer, 76 int frames_per_buffer,
81 PepperAudioInputHost* client); 77 PepperAudioInputHost* client);
82 78
83 // I/O thread backends to above functions. 79 // I/O thread backends to above functions.
84 void InitializeOnIOThread(int session_id); 80 void InitializeOnIOThread(int session_id);
85 void StartCaptureOnIOThread(); 81 void StartCaptureOnIOThread();
86 void StopCaptureOnIOThread(); 82 void StopCaptureOnIOThread();
87 void ShutDownOnIOThread(); 83 void ShutDownOnIOThread();
88 84
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool pending_open_device_; 121 bool pending_open_device_;
126 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. 122 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD.
127 int pending_open_device_id_; 123 int pending_open_device_id_;
128 124
129 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInput); 125 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInput);
130 }; 126 };
131 127
132 } // namespace content 128 } // namespace content
133 129
134 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_ 130 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_media_device_manager.cc ('k') | content/renderer/pepper/pepper_platform_audio_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698