Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/Utils.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Remove a #include Utils.h from test. Created June 2, 2017, 7:38 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/Utils.h ('k') | test/BaseJsTest.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 17 matching lines...) Expand all
28 28
29 std::string Utils::FromV8String(const v8::Handle<v8::Value>& value) 29 std::string Utils::FromV8String(const v8::Handle<v8::Value>& value)
30 { 30 {
31 v8::String::Utf8Value stringValue(value); 31 v8::String::Utf8Value stringValue(value);
32 if (stringValue.length()) 32 if (stringValue.length())
33 return std::string(*stringValue, stringValue.length()); 33 return std::string(*stringValue, stringValue.length());
34 else 34 else
35 return std::string(); 35 return std::string();
36 } 36 }
37 37
38 StringBuffer Utils::StringBufferFromV8String(const v8::Handle<v8::Value>& value)
39 {
40 v8::String::Utf8Value stringValue(value);
41 if (stringValue.length())
42 return IFileSystem::IOBuffer(*stringValue, *stringValue + stringValue.length ());
43 else
44 return IFileSystem::IOBuffer();
45 }
46
38 v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str) 47 v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str)
39 { 48 {
40 return v8::String::NewFromUtf8(isolate, str.c_str(), 49 return v8::String::NewFromUtf8(isolate, str.c_str(),
41 v8::String::NewStringType::kNormalString, str.length()); 50 v8::String::NewStringType::kNormalString, str.length());
51 }
52
53 v8::Local<v8::String> Utils::StringBufferToV8String(v8::Isolate* isolate, const StringBuffer& str)
54 {
55 return v8::String::NewFromUtf8(isolate,
56 reinterpret_cast<const char*>(str.data()),
57 v8::String::NewStringType::kNormalString, str.size());
42 } 58 }
43 59
44 void Utils::ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str) 60 void Utils::ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str)
45 { 61 {
46 isolate->ThrowException(Utils::ToV8String(isolate, str)); 62 isolate->ThrowException(Utils::ToV8String(isolate, str));
47 } 63 }
48 64
49 #ifdef _WIN32 65 #ifdef _WIN32
50 std::wstring Utils::ToUtf16String(const std::string& str) 66 std::wstring Utils::ToUtf16String(const std::string& str)
51 { 67 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (FAILED(hr)) 109 if (FAILED(hr))
94 { 110 {
95 throw std::runtime_error("CanonizeUrl failed\n"); 111 throw std::runtime_error("CanonizeUrl failed\n");
96 } 112 }
97 } 113 }
98 return canonizedUrl; 114 return canonizedUrl;
99 115
100 } 116 }
101 #endif 117 #endif
102 118
LEFTRIGHT

Powered by Google App Engine
This is Rietveld