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

Unified Diff: src/WebRequestJsObject.cpp

Issue 10296001: Implement File API (Closed)
Patch Set: Address issues Created April 15, 2013, 1:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/WebRequestJsObject.cpp
===================================================================
--- a/src/WebRequestJsObject.cpp
+++ b/src/WebRequestJsObject.cpp
@@ -2,23 +2,10 @@
#include <AdblockPlus.h>
#include "WebRequestJsObject.h"
#include "Thread.h"
+#include "Utils.h"
namespace
{
- std::string fromV8String(v8::Handle<v8::Value> value)
- {
- v8::String::Utf8Value stringValue(value);
- if (stringValue.length())
- return std::string(*stringValue, stringValue.length());
- else
- return std::string();
- }
-
- v8::Local<v8::String> toV8String(const std::string& str)
- {
- return v8::String::New(str.c_str(), str.length());
- }
Wladimir Palant 2013/04/16 06:52:44 You might want to revert that change. My refactori
-
class WebRequestThread : public AdblockPlus::Thread
{
public:
@@ -26,7 +13,7 @@
: isolate(v8::Isolate::GetCurrent()),
context(v8::Persistent<v8::Context>::New(isolate, v8::Context::GetCurrent())),
thisPtr(v8::Persistent<v8::Object>::New(isolate, arguments.Holder())),
- url(fromV8String(arguments[0]))
+ url(AdblockPlus::Utils::FromV8String(arguments[0]))
{
const v8::Locker locker(isolate);
const v8::HandleScope handleScope;
@@ -43,8 +30,8 @@
for (unsigned i = 0; i < properties->Length(); i++)
{
const v8::Local<v8::Value> property = properties->Get(i);
- std::string header = fromV8String(property);
- std::string headerValue = fromV8String(object->Get(property));
+ std::string header = AdblockPlus::Utils::FromV8String(property);
+ std::string headerValue = AdblockPlus::Utils::FromV8String(object->Get(property));
if (header.length() && headerValue.length())
headers.push_back(std::pair<std::string, std::string>(header, headerValue));
}
@@ -78,13 +65,13 @@
v8::Local<v8::Object> resultObject = v8::Object::New();
resultObject->Set(v8::String::New("status"), v8::Number::New(result.status));
resultObject->Set(v8::String::New("responseStatus"), v8::Integer::New(result.responseStatus));
- resultObject->Set(v8::String::New("responseText"), toV8String(result.responseText));
+ resultObject->Set(v8::String::New("responseText"), AdblockPlus::Utils::ToV8String(result.responseText));
v8::Local<v8::Object> headersObject = v8::Object::New();
for (AdblockPlus::HeaderList::iterator it = result.responseHeaders.begin();
it != result.responseHeaders.end(); ++it)
{
- headersObject->Set(toV8String(it->first), toV8String(it->second));
+ headersObject->Set(AdblockPlus::Utils::ToV8String(it->first), AdblockPlus::Utils::ToV8String(it->second));
}
resultObject->Set(v8::String::New("responseHeaders"), headersObject);
« src/FileSystemJsObject.cpp ('K') | « src/Utils.cpp ('k') | test/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld