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

Side by Side Diff: chrome/renderer/extensions/cast_streaming_native_handler.cc

Issue 107083006: More v8-API-related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/renderer/extensions/cast_streaming_native_handler.h" 5 #include "chrome/renderer/extensions/cast_streaming_native_handler.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 weak_factory_.GetWeakPtr(), 189 weak_factory_.GetWeakPtr(),
190 base::Passed(&stream1), 190 base::Passed(&stream1),
191 base::Passed(&stream2), 191 base::Passed(&stream2),
192 base::Passed(&udp_transport))); 192 base::Passed(&udp_transport)));
193 } 193 }
194 194
195 void CastStreamingNativeHandler::CallCreateCallback( 195 void CastStreamingNativeHandler::CallCreateCallback(
196 scoped_ptr<CastRtpStream> stream1, 196 scoped_ptr<CastRtpStream> stream1,
197 scoped_ptr<CastRtpStream> stream2, 197 scoped_ptr<CastRtpStream> stream2,
198 scoped_ptr<CastUdpTransport> udp_transport) { 198 scoped_ptr<CastUdpTransport> udp_transport) {
199 v8::HandleScope handle_scope(context()->isolate()); 199 v8::Isolate* isolate = context()->isolate();
200 v8::HandleScope handle_scope(isolate);
200 v8::Context::Scope context_scope(context()->v8_context()); 201 v8::Context::Scope context_scope(context()->v8_context());
201 202
202 const int stream1_id = last_transport_id_++; 203 const int stream1_id = last_transport_id_++;
203 rtp_stream_map_[stream1_id] = 204 rtp_stream_map_[stream1_id] =
204 linked_ptr<CastRtpStream>(stream1.release()); 205 linked_ptr<CastRtpStream>(stream1.release());
205 const int stream2_id = last_transport_id_++; 206 const int stream2_id = last_transport_id_++;
206 rtp_stream_map_[stream2_id] = 207 rtp_stream_map_[stream2_id] =
207 linked_ptr<CastRtpStream>(stream2.release()); 208 linked_ptr<CastRtpStream>(stream2.release());
208 const int udp_id = last_transport_id_++; 209 const int udp_id = last_transport_id_++;
209 udp_transport_map_[udp_id] = 210 udp_transport_map_[udp_id] =
210 linked_ptr<CastUdpTransport>(udp_transport.release()); 211 linked_ptr<CastUdpTransport>(udp_transport.release());
211 212
212 v8::Handle<v8::Value> callback_args[3]; 213 v8::Handle<v8::Value> callback_args[3];
213 callback_args[0] = v8::Integer::New(stream1_id); 214 callback_args[0] = v8::Integer::New(isolate, stream1_id);
214 callback_args[1] = v8::Integer::New(stream2_id); 215 callback_args[1] = v8::Integer::New(isolate, stream2_id);
215 callback_args[2] = v8::Integer::New(udp_id); 216 callback_args[2] = v8::Integer::New(isolate, udp_id);
216 context()->CallFunction(create_callback_.NewHandle(context()->isolate()), 217 context()->CallFunction(create_callback_.NewHandle(isolate),
217 3, callback_args); 218 3, callback_args);
218 create_callback_.reset(); 219 create_callback_.reset();
219 } 220 }
220 221
221 void CastStreamingNativeHandler::DestroyCastRtpStream( 222 void CastStreamingNativeHandler::DestroyCastRtpStream(
222 const v8::FunctionCallbackInfo<v8::Value>& args) { 223 const v8::FunctionCallbackInfo<v8::Value>& args) {
223 CHECK_EQ(1, args.Length()); 224 CHECK_EQ(1, args.Length());
224 CHECK(args[0]->IsInt32()); 225 CHECK(args[0]->IsInt32());
225 226
226 const int transport_id = args[0]->ToInt32()->Value(); 227 const int transport_id = args[0]->ToInt32()->Value();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 transport_id); 356 transport_id);
356 if (iter != udp_transport_map_.end()) 357 if (iter != udp_transport_map_.end())
357 return iter->second.get(); 358 return iter->second.get();
358 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); 359 v8::Isolate* isolate = context()->v8_context()->GetIsolate();
359 isolate->ThrowException(v8::Exception::RangeError( 360 isolate->ThrowException(v8::Exception::RangeError(
360 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); 361 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound)));
361 return NULL; 362 return NULL;
362 } 363 }
363 364
364 } // namespace extensions 365 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/app_window_custom_bindings.cc ('k') | chrome/renderer/extensions/chrome_v8_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698