Implement video frame acknowledgements in the chromoting protocol.
[chromium-blink-merge.git] / chrome / renderer / extensions / page_capture_custom_bindings.cc
blobd3086e94e54562892ff05c4ad84d83a623f0e210
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
3 // found in the LICENSE file.
5 #include "chrome/renderer/extensions/page_capture_custom_bindings.h"
7 #include "base/bind.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/renderer/render_view.h"
10 #include "extensions/common/extension_messages.h"
11 #include "extensions/renderer/script_context.h"
12 #include "third_party/WebKit/public/web/WebBlob.h"
13 #include "v8/include/v8.h"
15 namespace extensions {
17 PageCaptureCustomBindings::PageCaptureCustomBindings(ScriptContext* context)
18 : ObjectBackedNativeHandler(context) {
19 RouteFunction("CreateBlob",
20 base::Bind(&PageCaptureCustomBindings::CreateBlob,
21 base::Unretained(this)));
22 RouteFunction("SendResponseAck",
23 base::Bind(&PageCaptureCustomBindings::SendResponseAck,
24 base::Unretained(this)));
27 void PageCaptureCustomBindings::CreateBlob(
28 const v8::FunctionCallbackInfo<v8::Value>& args) {
29 CHECK(args.Length() == 2);
30 CHECK(args[0]->IsString());
31 CHECK(args[1]->IsInt32());
32 blink::WebString path(base::UTF8ToUTF16(*v8::String::Utf8Value(args[0])));
33 blink::WebBlob blob =
34 blink::WebBlob::createFromFile(path, args[1]->Int32Value());
35 args.GetReturnValue().Set(blob.toV8Value(args.Holder(), args.GetIsolate()));
38 void PageCaptureCustomBindings::SendResponseAck(
39 const v8::FunctionCallbackInfo<v8::Value>& args) {
40 CHECK(args.Length() == 1);
41 CHECK(args[0]->IsInt32());
43 content::RenderView* render_view = context()->GetRenderView();
44 if (render_view) {
45 render_view->Send(new ExtensionHostMsg_ResponseAck(
46 render_view->GetRoutingID(), args[0]->Int32Value()));
50 } // namespace extensions