Use ExtensionRegistry::enabled_extensions instead of deprecated ExtensionService...
[chromium-blink-merge.git] / ppapi / proxy / media_stream_track_resource_base.cc
blobd259036f376fbcde13973f79dcb56e7554180573
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
3 // found in the LICENSE file.
5 #include "ppapi/proxy/media_stream_track_resource_base.h"
7 #include "base/logging.h"
8 #include "ppapi/proxy/ppapi_messages.h"
10 namespace ppapi {
11 namespace proxy {
13 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase(
14 Connection connection,
15 PP_Instance instance,
16 int pending_renderer_id,
17 const std::string& id)
18 : PluginResource(connection, instance),
19 buffer_manager_(this),
20 id_(id),
21 has_ended_(false) {
22 AttachToPendingHost(RENDERER, pending_renderer_id);
25 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
28 void MediaStreamTrackResourceBase::SendEnqueueBufferMessageToHost(
29 int32_t index) {
30 DCHECK_GE(index, 0);
31 DCHECK_LT(index, buffer_manager()->number_of_buffers());
32 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueBuffer(index));
35 void MediaStreamTrackResourceBase::OnReplyReceived(
36 const ResourceMessageReplyParams& params,
37 const IPC::Message& msg) {
38 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg)
39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
40 PpapiPluginMsg_MediaStreamTrack_InitBuffers, OnPluginMsgInitBuffers)
41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
42 PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer, OnPluginMsgEnqueueBuffer)
43 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
44 PluginResource::OnReplyReceived(params, msg))
45 IPC_END_MESSAGE_MAP()
48 void MediaStreamTrackResourceBase::CloseInternal() {
49 if (!has_ended_) {
50 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
51 has_ended_ = true;
55 void MediaStreamTrackResourceBase::OnPluginMsgInitBuffers(
56 const ResourceMessageReplyParams& params,
57 int32_t number_of_buffers,
58 int32_t buffer_size) {
59 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
60 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
61 buffer_manager_.SetBuffers(number_of_buffers, buffer_size,
62 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)),
63 false);
66 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueBuffer(
67 const ResourceMessageReplyParams& params,
68 int32_t index) {
69 buffer_manager_.EnqueueBuffer(index);
72 } // namespace proxy
73 } // namespace ppapi