Fix protocol module specs.

This commit is contained in:
Cheng Zhao 2013-12-15 16:53:07 +08:00
parent cfeeec37eb
commit 474e1fcd3b

View file

@ -188,7 +188,7 @@ void Protocol::RegisterProtocol(
return node::ThrowTypeError("Bad argument"); return node::ThrowTypeError("Bad argument");
if (g_handlers.find(scheme) != g_handlers.end() || if (g_handlers.find(scheme) != g_handlers.end() ||
net::URLRequest::IsHandledProtocol(scheme)) GetRequestJobFactory()->IsHandledProtocol(scheme))
return node::ThrowError("The scheme is already registered"); return node::ThrowError("The scheme is already registered");
if (AtomBrowserContext::Get()->url_request_context_getter() == NULL) if (AtomBrowserContext::Get()->url_request_context_getter() == NULL)
@ -226,8 +226,11 @@ void Protocol::UnregisterProtocol(
// static // static
void Protocol::IsHandledProtocol( void Protocol::IsHandledProtocol(
const v8::FunctionCallbackInfo<v8::Value>& args) { const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string scheme = FromV8Value(args[0]); std::string scheme;
args.GetReturnValue().Set(net::URLRequest::IsHandledProtocol(scheme)); if (!FromV8Arguments(args, &scheme))
return node::ThrowTypeError("Bad argument");
args.GetReturnValue().Set(GetRequestJobFactory()->IsHandledProtocol(scheme));
} }
// static // static
@ -361,7 +364,7 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) {
// static // static
void Protocol::Initialize(v8::Handle<v8::Object> target) { void Protocol::Initialize(v8::Handle<v8::Object> target) {
// Remember the protocol object, used for emitting event later. // Remember the protocol object, used for emitting event later.
g_protocol_object.reset(v8::Object::New()); g_protocol_object.reset(target);
NODE_SET_METHOD(target, "registerProtocol", RegisterProtocol); NODE_SET_METHOD(target, "registerProtocol", RegisterProtocol);
NODE_SET_METHOD(target, "unregisterProtocol", UnregisterProtocol); NODE_SET_METHOD(target, "unregisterProtocol", UnregisterProtocol);