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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 525313002: SyncSocket Transit Descriptor - refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits done - Prelanding checks Created 6 years, 3 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/sync_socket.h" 9 #include "base/sync_socket.h"
10 #include "content/browser/media/capture/audio_mirroring_manager.h" 10 #include "content/browser/media/capture/audio_mirroring_manager.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged, 94 IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged,
95 OnNotifyStreamStateChanged) 95 OnNotifyStreamStateChanged)
96 IPC_MESSAGE_UNHANDLED(handled = false) 96 IPC_MESSAGE_UNHANDLED(handled = false)
97 IPC_END_MESSAGE_MAP() 97 IPC_END_MESSAGE_MAP()
98 EXPECT_TRUE(handled); 98 EXPECT_TRUE(handled);
99 99
100 delete message; 100 delete message;
101 return true; 101 return true;
102 } 102 }
103 103
104 void OnNotifyStreamCreated(int stream_id, 104 void OnNotifyStreamCreated(
105 base::SharedMemoryHandle handle, 105 int stream_id, base::SharedMemoryHandle handle,
106 #if defined(OS_WIN) 106 base::SyncSocket::TransitDescriptor socket_descriptor, uint32 length) {
107 base::SyncSocket::Handle socket_handle,
108 #else
109 base::FileDescriptor socket_descriptor,
110 #endif
111 uint32 length) {
112 // Maps the shared memory. 107 // Maps the shared memory.
113 shared_memory_.reset(new base::SharedMemory(handle, false)); 108 shared_memory_.reset(new base::SharedMemory(handle, false));
114 CHECK(shared_memory_->Map(length)); 109 CHECK(shared_memory_->Map(length));
115 CHECK(shared_memory_->memory()); 110 CHECK(shared_memory_->memory());
116 shared_memory_length_ = length; 111 shared_memory_length_ = length;
117 112
118 // Create the SyncSocket using the handle. 113 // Create the SyncSocket using the handle.
119 base::SyncSocket::Handle sync_socket_handle; 114 base::SyncSocket::Handle sync_socket_handle =
120 #if defined(OS_WIN) 115 base::SyncSocket::UnwrapHandle(socket_descriptor);
121 sync_socket_handle = socket_handle;
122 #else
123 sync_socket_handle = socket_descriptor.fd;
124 #endif
125 sync_socket_.reset(new base::SyncSocket(sync_socket_handle)); 116 sync_socket_.reset(new base::SyncSocket(sync_socket_handle));
126 117
127 // And then delegate the call to the mock method. 118 // And then delegate the call to the mock method.
128 OnStreamCreated(stream_id, length); 119 OnStreamCreated(stream_id, length);
129 } 120 }
130 121
131 void OnNotifyStreamStateChanged(int stream_id, 122 void OnNotifyStreamStateChanged(int stream_id,
132 media::AudioOutputIPCDelegate::State state) { 123 media::AudioOutputIPCDelegate::State state) {
133 switch (state) { 124 switch (state) {
134 case media::AudioOutputIPCDelegate::kPlaying: 125 case media::AudioOutputIPCDelegate::kPlaying:
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 337 }
347 338
348 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) { 339 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) {
349 Create(true); 340 Create(true);
350 Close(); 341 Close();
351 } 342 }
352 343
353 // TODO(hclam): Add tests for data conversation in low latency mode. 344 // TODO(hclam): Add tests for data conversation in low latency mode.
354 345
355 } // namespace content 346 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.cc ('k') | content/browser/renderer_host/media/audio_sync_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698