| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "extensions/renderer/app_runtime_custom_bindings.h" | 5 #include "extensions/renderer/app_runtime_custom_bindings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "third_party/WebKit/public/platform/WebCString.h" | 9 #include "third_party/WebKit/public/platform/WebCString.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DCHECK(args.Length() == 2); | 42 DCHECK(args.Length() == 2); |
| 43 DCHECK(args[0]->IsString()); | 43 DCHECK(args[0]->IsString()); |
| 44 DCHECK(args[1]->IsNumber()); | 44 DCHECK(args[1]->IsNumber()); |
| 45 | 45 |
| 46 std::string blob_file_path(*v8::String::Utf8Value(args[0])); | 46 std::string blob_file_path(*v8::String::Utf8Value(args[0])); |
| 47 std::string blob_length_string(*v8::String::Utf8Value(args[1])); | 47 std::string blob_length_string(*v8::String::Utf8Value(args[1])); |
| 48 int64 blob_length = 0; | 48 int64 blob_length = 0; |
| 49 DCHECK(base::StringToInt64(blob_length_string, &blob_length)); | 49 DCHECK(base::StringToInt64(blob_length_string, &blob_length)); |
| 50 blink::WebBlob web_blob = | 50 blink::WebBlob web_blob = |
| 51 WebBlob::createFromFile(WebString::fromUTF8(blob_file_path), blob_length); | 51 WebBlob::createFromFile(WebString::fromUTF8(blob_file_path), blob_length); |
| 52 args.GetReturnValue().Set(web_blob.toV8Value()); | 52 args.GetReturnValue().Set( |
| 53 web_blob.toV8Value(args.Holder(), args.GetIsolate())); |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 namespace extensions { | 58 namespace extensions { |
| 58 | 59 |
| 59 AppRuntimeCustomBindings::AppRuntimeCustomBindings(ScriptContext* context) | 60 AppRuntimeCustomBindings::AppRuntimeCustomBindings(ScriptContext* context) |
| 60 : ObjectBackedNativeHandler(context) { | 61 : ObjectBackedNativeHandler(context) { |
| 61 RouteFunction("DeserializeString", base::Bind(&DeserializeString)); | 62 RouteFunction("DeserializeString", base::Bind(&DeserializeString)); |
| 62 RouteFunction("SerializeToString", base::Bind(&SerializeToString)); | 63 RouteFunction("SerializeToString", base::Bind(&SerializeToString)); |
| 63 RouteFunction("CreateBlob", base::Bind(&CreateBlob)); | 64 RouteFunction("CreateBlob", base::Bind(&CreateBlob)); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace extensions | 67 } // namespace extensions |
| OLD | NEW |