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

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

Issue 8965053: Implement support for a cancelable SyncSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed micro-nit Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/media/audio_sync_reader.h" 5 #include "content/browser/renderer_host/media/audio_sync_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void AudioSyncReader::Close() { 86 void AudioSyncReader::Close() {
87 base::AutoLock auto_lock(lock_); 87 base::AutoLock auto_lock(lock_);
88 if (socket_.get()) { 88 if (socket_.get()) {
89 socket_->Close(); 89 socket_->Close();
90 socket_.reset(NULL); 90 socket_.reset(NULL);
91 } 91 }
92 } 92 }
93 93
94 bool AudioSyncReader::Init() { 94 bool AudioSyncReader::Init() {
95 base::SyncSocket* sockets[2] = {0}; 95 socket_.reset(new base::SyncSocket());
96 if (base::SyncSocket::CreatePair(sockets)) { 96 foreign_socket_.reset(new base::SyncSocket());
97 socket_.reset(sockets[0]); 97 return base::SyncSocket::CreatePair(socket_.get(), foreign_socket_.get());
98 foreign_socket_.reset(sockets[1]);
99 return true;
100 }
101 return false;
102 } 98 }
103 99
104 #if defined(OS_WIN) 100 #if defined(OS_WIN)
105 bool AudioSyncReader::PrepareForeignSocketHandle( 101 bool AudioSyncReader::PrepareForeignSocketHandle(
106 base::ProcessHandle process_handle, 102 base::ProcessHandle process_handle,
107 base::SyncSocket::Handle* foreign_handle) { 103 base::SyncSocket::Handle* foreign_handle) {
108 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(), 104 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(),
109 process_handle, foreign_handle, 105 process_handle, foreign_handle,
110 0, FALSE, DUPLICATE_SAME_ACCESS); 106 0, FALSE, DUPLICATE_SAME_ACCESS);
111 if (*foreign_handle != 0) 107 if (*foreign_handle != 0)
112 return true; 108 return true;
113 return false; 109 return false;
114 } 110 }
115 #else 111 #else
116 bool AudioSyncReader::PrepareForeignSocketHandle( 112 bool AudioSyncReader::PrepareForeignSocketHandle(
117 base::ProcessHandle process_handle, 113 base::ProcessHandle process_handle,
118 base::FileDescriptor* foreign_handle) { 114 base::FileDescriptor* foreign_handle) {
119 foreign_handle->fd = foreign_socket_->handle(); 115 foreign_handle->fd = foreign_socket_->handle();
120 foreign_handle->auto_close = false; 116 foreign_handle->auto_close = false;
121 if (foreign_handle->fd != -1) 117 if (foreign_handle->fd != -1)
122 return true; 118 return true;
123 return false; 119 return false;
124 } 120 }
125 #endif 121 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_input_sync_writer.cc ('k') | content/renderer/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698