From fed94aada0870f8fd042cf8e53337f37dac698b9 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 11 Dec 2015 23:54:32 +0800 Subject: [PATCH] Make the webRequest listener asynchronous --- atom/browser/api/atom_api_web_contents.cc | 1 + atom/browser/api/atom_api_web_request.cc | 45 ++-- atom/browser/api/atom_api_web_request.h | 9 +- atom/browser/net/atom_network_delegate.cc | 231 +++++++++++------- atom/browser/net/atom_network_delegate.h | 49 ++-- .../native_mate_converters/net_converter.cc | 34 --- .../native_mate_converters/net_converter.h | 8 - 7 files changed, 197 insertions(+), 180 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a70b6cf4e0b2..cb89db911f06 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -5,6 +5,7 @@ #include "atom/browser/api/atom_api_web_contents.h" #include +#include #include "atom/browser/api/atom_api_session.h" #include "atom/browser/api/atom_api_window.h" diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc index 5b9d2fbe640f..7b39c59423de 100644 --- a/atom/browser/api/atom_api_web_request.cc +++ b/atom/browser/api/atom_api_web_request.cc @@ -41,8 +41,20 @@ WebRequest::WebRequest(AtomBrowserContext* browser_context) WebRequest::~WebRequest() { } -template -void WebRequest::SetListener(mate::Arguments* args) { +template +void WebRequest::SetSimpleListener(mate::Arguments* args) { + SetListener( + &AtomNetworkDelegate::SetSimpleListenerInIO, type, args); +} + +template +void WebRequest::SetResponseListener(mate::Arguments* args) { + SetListener( + &AtomNetworkDelegate::SetResponseListenerInIO, type, args); +} + +template +void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) { // { urls }. URLPatterns patterns; mate::Dictionary dict; @@ -50,8 +62,8 @@ void WebRequest::SetListener(mate::Arguments* args) { // Function or null. v8::Local value; - AtomNetworkDelegate::Listener callback; - if (!args->GetNext(&callback) && + Listener listener; + if (!args->GetNext(&listener) && !(args->GetNext(&value) && value->IsNull())) { args->ThrowError("Must pass null or a Function"); return; @@ -59,9 +71,8 @@ void WebRequest::SetListener(mate::Arguments* args) { auto delegate = browser_context_->network_delegate(); BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&AtomNetworkDelegate::SetListenerInIO, - base::Unretained(delegate), - type, patterns, callback)); + base::Bind(method, base::Unretained(delegate), type, + patterns, listener)); } // static @@ -76,28 +87,28 @@ void WebRequest::BuildPrototype(v8::Isolate* isolate, v8::Local prototype) { mate::ObjectTemplateBuilder(isolate, prototype) .SetMethod("onBeforeRequest", - &WebRequest::SetListener< + &WebRequest::SetResponseListener< AtomNetworkDelegate::kOnBeforeRequest>) .SetMethod("onBeforeSendHeaders", - &WebRequest::SetListener< + &WebRequest::SetResponseListener< AtomNetworkDelegate::kOnBeforeSendHeaders>) - .SetMethod("onSendHeaders", - &WebRequest::SetListener< - AtomNetworkDelegate::kOnSendHeaders>) .SetMethod("onHeadersReceived", - &WebRequest::SetListener< + &WebRequest::SetResponseListener< AtomNetworkDelegate::kOnHeadersReceived>) + .SetMethod("onSendHeaders", + &WebRequest::SetSimpleListener< + AtomNetworkDelegate::kOnSendHeaders>) .SetMethod("onBeforeRedirect", - &WebRequest::SetListener< + &WebRequest::SetSimpleListener< AtomNetworkDelegate::kOnBeforeRedirect>) .SetMethod("onResponseStarted", - &WebRequest::SetListener< + &WebRequest::SetSimpleListener< AtomNetworkDelegate::kOnResponseStarted>) .SetMethod("onCompleted", - &WebRequest::SetListener< + &WebRequest::SetSimpleListener< AtomNetworkDelegate::kOnCompleted>) .SetMethod("onErrorOccurred", - &WebRequest::SetListener< + &WebRequest::SetSimpleListener< AtomNetworkDelegate::kOnErrorOccurred>); } diff --git a/atom/browser/api/atom_api_web_request.h b/atom/browser/api/atom_api_web_request.h index 0292a00104b4..9a6e17a04605 100644 --- a/atom/browser/api/atom_api_web_request.h +++ b/atom/browser/api/atom_api_web_request.h @@ -29,8 +29,13 @@ class WebRequest : public mate::TrackableObject { explicit WebRequest(AtomBrowserContext* browser_context); ~WebRequest(); - template - void SetListener(mate::Arguments* args); + // C++ can not distinguish overloaded member function. + template + void SetSimpleListener(mate::Arguments* args); + template + void SetResponseListener(mate::Arguments* args); + template + void SetListener(Method method, Event type, mate::Arguments* args); private: scoped_refptr browser_context_; diff --git a/atom/browser/net/atom_network_delegate.cc b/atom/browser/net/atom_network_delegate.cc index d536b0f8a912..4b58a8cc6e75 100644 --- a/atom/browser/net/atom_network_delegate.cc +++ b/atom/browser/net/atom_network_delegate.cc @@ -4,6 +4,8 @@ #include "atom/browser/net/atom_network_delegate.h" +#include + #include "atom/common/native_mate_converters/net_converter.h" #include "base/stl_util.h" #include "base/strings/string_util.h" @@ -38,12 +40,19 @@ const char* ResourceTypeToString(content::ResourceType type) { } } -AtomNetworkDelegate::BlockingResponse RunListener( - const AtomNetworkDelegate::Listener& callback, - scoped_ptr details) { - return callback.Run(*(details.get())); +void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener, + scoped_ptr details) { + return listener.Run(*(details.get())); } +void RunResponseListener( + const AtomNetworkDelegate::ResponseListener& listener, + scoped_ptr details, + const AtomNetworkDelegate::ResponseCallback& callback) { + return listener.Run(*(details.get()), callback); +} + +// Test whether the URL of |request| matches |patterns|. bool MatchesFilterCondition(net::URLRequest* request, const URLPatterns& patterns) { if (patterns.empty()) @@ -56,6 +65,7 @@ bool MatchesFilterCondition(net::URLRequest* request, return false; } +// Overloaded by multiple types to fill the |details| object. void FillDetailsObject(base::DictionaryValue* details, net::URLRequest* request) { details->SetInteger("id", request->identifier()); @@ -122,41 +132,65 @@ void FillDetailsObject(base::DictionaryValue* details, details->SetString("error", net::ErrorToString(status.error())); } -void OnBeforeURLRequestResponse( - const net::CompletionCallback& callback, - GURL* new_url, - const AtomNetworkDelegate::BlockingResponse& result) { - if (!result.redirect_url.is_empty()) - *new_url = result.redirect_url; - callback.Run(result.code()); +// Fill the native types with the result from the response object. +void ReadFromResponseObject(const base::DictionaryValue& response, + GURL* new_location) { + std::string url; + if (response.GetString("redirectURL", &url)) + *new_location = GURL(url); } -void OnBeforeSendHeadersResponse( - const net::CompletionCallback& callback, - net::HttpRequestHeaders* headers, - const AtomNetworkDelegate::BlockingResponse& result) { - if (!result.request_headers.IsEmpty()) - *headers = result.request_headers; - callback.Run(result.code()); -} - -void OnHeadersReceivedResponse( - const net::CompletionCallback& callback, - const net::HttpResponseHeaders* original_response_headers, - scoped_refptr* override_response_headers, - const AtomNetworkDelegate::BlockingResponse& result) { - if (result.response_headers.get()) { - *override_response_headers = new net::HttpResponseHeaders( - original_response_headers->raw_headers()); - void* iter = nullptr; - std::string key; - std::string value; - while (result.response_headers->EnumerateHeaderLines(&iter, &key, &value)) { - (*override_response_headers)->RemoveHeader(key); - (*override_response_headers)->AddHeader(key + ": " + value); +void ReadFromResponseObject(const base::DictionaryValue& response, + net::HttpRequestHeaders* headers) { + const base::DictionaryValue* dict; + if (response.GetDictionary("requestHeaders", &dict)) { + for (base::DictionaryValue::Iterator it(*dict); + !it.IsAtEnd(); + it.Advance()) { + std::string value; + if (it.value().GetAsString(&value)) + headers->SetHeader(it.key(), value); } } - callback.Run(result.code()); +} + +void ReadFromResponseObject(const base::DictionaryValue& response, + scoped_refptr* headers) { + const base::DictionaryValue* dict; + if (response.GetDictionary("responseHeaders", &dict)) { + *headers = new net::HttpResponseHeaders(""); + for (base::DictionaryValue::Iterator it(*dict); + !it.IsAtEnd(); + it.Advance()) { + std::string value; + if (it.value().GetAsString(&value)) { + (*headers)->RemoveHeader(it.key()); + (*headers)->AddHeader(it.key() + " : " + value); + } + } + } +} + +// Deal with the results of Listener. +template +void OnListenerResultInIO(const net::CompletionCallback& callback, + T out, + scoped_ptr response) { + ReadFromResponseObject(*response.get(), out); + + bool cancel = false; + response->GetBoolean("cancel", &cancel); + callback.Run(cancel ? net::ERR_BLOCKED_BY_CLIENT : net::OK); +} + +template +void OnListenerResultInUI(const net::CompletionCallback& callback, + T out, + const base::DictionaryValue& response) { + scoped_ptr copy = response.CreateDeepCopy(); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(OnListenerResultInIO, callback, out, base::Passed(©))); } } // namespace @@ -167,36 +201,47 @@ AtomNetworkDelegate::AtomNetworkDelegate() { AtomNetworkDelegate::~AtomNetworkDelegate() { } -void AtomNetworkDelegate::SetListenerInIO(EventType type, - const URLPatterns& patterns, - const Listener& callback) { - if (callback.is_null()) { - event_listener_map_.erase(type); - return; - } +void AtomNetworkDelegate::SetSimpleListenerInIO( + SimpleEvent type, + const URLPatterns& patterns, + const SimpleListener& callback) { + if (callback.is_null()) + simple_listeners_.erase(type); + else + simple_listeners_[type] = { patterns, callback }; +} - event_listener_map_[type] = { patterns, callback }; +void AtomNetworkDelegate::SetResponseListenerInIO( + ResponseEvent type, + const URLPatterns& patterns, + const ResponseListener& callback) { + if (callback.is_null()) + response_listeners_.erase(type); + else + response_listeners_[type] = { patterns, callback }; } int AtomNetworkDelegate::OnBeforeURLRequest( net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) { - if (!ContainsKey(event_listener_map_, kOnBeforeRequest)) + if (!ContainsKey(response_listeners_, kOnBeforeRequest)) return brightray::NetworkDelegate::OnBeforeURLRequest( request, callback, new_url); - const ListenerInfo& info = event_listener_map_[kOnBeforeRequest]; + const auto& info = response_listeners_[kOnBeforeRequest]; if (!MatchesFilterCondition(request, info.url_patterns)) return net::OK; scoped_ptr details(new base::DictionaryValue); FillDetailsObject(details.get(), request); - BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, - base::Bind(&RunListener, info.callback, base::Passed(&details)), - base::Bind(&OnBeforeURLRequestResponse, - callback, new_url)); + ResponseCallback response = + base::Bind(OnListenerResultInUI, callback, new_url); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunResponseListener, info.listener, base::Passed(&details), + response)); return net::ERR_IO_PENDING; } @@ -204,11 +249,11 @@ int AtomNetworkDelegate::OnBeforeSendHeaders( net::URLRequest* request, const net::CompletionCallback& callback, net::HttpRequestHeaders* headers) { - if (!ContainsKey(event_listener_map_, kOnBeforeSendHeaders)) + if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders)) return brightray::NetworkDelegate::OnBeforeSendHeaders( request, callback, headers); - const ListenerInfo& info = event_listener_map_[kOnBeforeSendHeaders]; + const auto& info = response_listeners_[kOnBeforeSendHeaders]; if (!MatchesFilterCondition(request, info.url_patterns)) return net::OK; @@ -216,22 +261,25 @@ int AtomNetworkDelegate::OnBeforeSendHeaders( FillDetailsObject(details.get(), request); FillDetailsObject(details.get(), *headers); - BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, - base::Bind(&RunListener, info.callback, base::Passed(&details)), - base::Bind(&OnBeforeSendHeadersResponse, - callback, headers)); + ResponseCallback response = + base::Bind(OnListenerResultInUI, + callback, headers); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunResponseListener, info.listener, base::Passed(&details), + response)); return net::ERR_IO_PENDING; } void AtomNetworkDelegate::OnSendHeaders( net::URLRequest* request, const net::HttpRequestHeaders& headers) { - if (!ContainsKey(event_listener_map_, kOnSendHeaders)) { + if (!ContainsKey(simple_listeners_, kOnSendHeaders)) { brightray::NetworkDelegate::OnSendHeaders(request, headers); return; } - const ListenerInfo& info = event_listener_map_[kOnSendHeaders]; + const auto& info = simple_listeners_[kOnSendHeaders]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -239,10 +287,9 @@ void AtomNetworkDelegate::OnSendHeaders( FillDetailsObject(details.get(), request); FillDetailsObject(details.get(), headers); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&RunListener), - info.callback, - base::Passed(&details))); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&RunSimpleListener, info.listener, base::Passed(&details))); } int AtomNetworkDelegate::OnHeadersReceived( @@ -251,12 +298,12 @@ int AtomNetworkDelegate::OnHeadersReceived( const net::HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, GURL* allowed_unsafe_redirect_url) { - if (!ContainsKey(event_listener_map_, kOnHeadersReceived)) + if (!ContainsKey(response_listeners_, kOnHeadersReceived)) return brightray::NetworkDelegate::OnHeadersReceived( request, callback, original_response_headers, override_response_headers, allowed_unsafe_redirect_url); - const ListenerInfo& info = event_listener_map_[kOnHeadersReceived]; + const auto& info = response_listeners_[kOnHeadersReceived]; if (!MatchesFilterCondition(request, info.url_patterns)) return net::OK; @@ -264,23 +311,24 @@ int AtomNetworkDelegate::OnHeadersReceived( FillDetailsObject(details.get(), request); FillDetailsObject(details.get(), original_response_headers); - BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, - base::Bind(&RunListener, info.callback, base::Passed(&details)), - base::Bind(&OnHeadersReceivedResponse, - callback, - original_response_headers, - override_response_headers)); + ResponseCallback response = + base::Bind(OnListenerResultInUI*>, + callback, override_response_headers); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunResponseListener, info.listener, base::Passed(&details), + response)); return net::ERR_IO_PENDING; } void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, const GURL& new_location) { - if (!ContainsKey(event_listener_map_, kOnBeforeRedirect)) { + if (!ContainsKey(simple_listeners_, kOnBeforeRedirect)) { brightray::NetworkDelegate::OnBeforeRedirect(request, new_location); return; } - const ListenerInfo& info = event_listener_map_[kOnBeforeRedirect]; + const auto& info = simple_listeners_[kOnBeforeRedirect]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -291,14 +339,13 @@ void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, FillDetailsObject(details.get(), request->GetSocketAddress()); FillDetailsObject(details.get(), request->was_cached()); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&RunListener), - info.callback, - base::Passed(&details))); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&RunSimpleListener, info.listener, base::Passed(&details))); } void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) { - if (!ContainsKey(event_listener_map_, kOnResponseStarted)) { + if (!ContainsKey(simple_listeners_, kOnResponseStarted)) { brightray::NetworkDelegate::OnResponseStarted(request); return; } @@ -306,7 +353,7 @@ void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) { if (request->status().status() != net::URLRequestStatus::SUCCESS) return; - const ListenerInfo& info = event_listener_map_[kOnResponseStarted]; + const auto& info = simple_listeners_[kOnResponseStarted]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -315,17 +362,16 @@ void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) { FillDetailsObject(details.get(), request->response_headers()); FillDetailsObject(details.get(), request->was_cached()); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&RunListener), - info.callback, - base::Passed(&details))); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunSimpleListener, info.listener, base::Passed(&details))); } void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { if (request->status().status() == net::URLRequestStatus::FAILED || request->status().status() == net::URLRequestStatus::CANCELED) { // Error event. - if (ContainsKey(event_listener_map_, kOnErrorOccurred)) + if (ContainsKey(simple_listeners_, kOnErrorOccurred)) OnErrorOccurred(request); else brightray::NetworkDelegate::OnCompleted(request, started); @@ -338,12 +384,12 @@ void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { return; } - if (!ContainsKey(event_listener_map_, kOnCompleted)) { + if (!ContainsKey(simple_listeners_, kOnCompleted)) { brightray::NetworkDelegate::OnCompleted(request, started); return; } - const ListenerInfo& info = event_listener_map_[kOnCompleted]; + const auto& info = simple_listeners_[kOnCompleted]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -352,15 +398,13 @@ void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { FillDetailsObject(details.get(), request->response_headers()); FillDetailsObject(details.get(), request->was_cached()); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&RunListener), - info.callback, - base::Passed(&details))); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunSimpleListener, info.listener, base::Passed(&details))); } void AtomNetworkDelegate::OnErrorOccurred(net::URLRequest* request) { - - const ListenerInfo& info = event_listener_map_[kOnErrorOccurred]; + const auto& info = simple_listeners_[kOnErrorOccurred]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -369,10 +413,9 @@ void AtomNetworkDelegate::OnErrorOccurred(net::URLRequest* request) { FillDetailsObject(details.get(), request->was_cached()); FillDetailsObject(details.get(), request->status()); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&RunListener), - info.callback, - base::Passed(&details))); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(RunSimpleListener, info.listener, base::Passed(&details))); } } // namespace atom diff --git a/atom/browser/net/atom_network_delegate.h b/atom/browser/net/atom_network_delegate.h index 671ef8201836..927dc58aa90f 100644 --- a/atom/browser/net/atom_network_delegate.h +++ b/atom/browser/net/atom_network_delegate.h @@ -26,46 +26,44 @@ using URLPatterns = std::set; class AtomNetworkDelegate : public brightray::NetworkDelegate { public: - struct BlockingResponse; - using Listener = - base::Callback; + using ResponseCallback = base::Callback; + using SimpleListener = base::Callback; + using ResponseListener = base::Callback; - enum EventType { - kOnBeforeRequest, - kOnBeforeSendHeaders, + enum SimpleEvent { kOnSendHeaders, - kOnHeadersReceived, kOnBeforeRedirect, kOnResponseStarted, kOnCompleted, kOnErrorOccurred, }; - struct ListenerInfo { - URLPatterns url_patterns; - AtomNetworkDelegate::Listener callback; + enum ResponseEvent { + kOnBeforeRequest, + kOnBeforeSendHeaders, + kOnHeadersReceived, }; - struct BlockingResponse { - BlockingResponse() : cancel(false) {} - ~BlockingResponse() {} + struct SimpleListenerInfo { + URLPatterns url_patterns; + SimpleListener listener; + }; - int code() const { - return cancel ? net::ERR_BLOCKED_BY_CLIENT : net::OK; - } - - bool cancel; - GURL redirect_url; - net::HttpRequestHeaders request_headers; - scoped_refptr response_headers; + struct ResponseListenerInfo { + URLPatterns url_patterns; + ResponseListener listener; }; AtomNetworkDelegate(); ~AtomNetworkDelegate() override; - void SetListenerInIO(EventType type, - const URLPatterns& patterns, - const Listener& callback); + void SetSimpleListenerInIO(SimpleEvent type, + const URLPatterns& patterns, + const SimpleListener& callback); + void SetResponseListenerInIO(ResponseEvent type, + const URLPatterns& patterns, + const ResponseListener& callback); protected: // net::NetworkDelegate: @@ -91,7 +89,8 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate { void OnErrorOccurred(net::URLRequest* request); private: - std::map event_listener_map_; + std::map simple_listeners_; + std::map response_listeners_;; DISALLOW_COPY_AND_ASSIGN(AtomNetworkDelegate); }; diff --git a/atom/common/native_mate_converters/net_converter.cc b/atom/common/native_mate_converters/net_converter.cc index ff0d3be88162..7a1b48d9311a 100644 --- a/atom/common/native_mate_converters/net_converter.cc +++ b/atom/common/native_mate_converters/net_converter.cc @@ -82,38 +82,4 @@ v8::Local Converter>::ToV8( return dict.GetHandle(); } -// static -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, - atom::AtomNetworkDelegate::BlockingResponse* out) { - mate::Dictionary dict; - if (!ConvertFromV8(isolate, val, &dict)) - return false; - if (!dict.Get("cancel", &(out->cancel))) - return false; - dict.Get("redirectURL", &(out->redirect_url)); - base::DictionaryValue request_headers; - if (dict.Get("requestHeaders", &request_headers)) { - for (base::DictionaryValue::Iterator it(request_headers); - !it.IsAtEnd(); - it.Advance()) { - std::string value; - CHECK(it.value().GetAsString(&value)); - out->request_headers.SetHeader(it.key(), value); - } - } - base::DictionaryValue response_headers; - if (dict.Get("responseHeaders", &response_headers)) { - out->response_headers = new net::HttpResponseHeaders(""); - for (base::DictionaryValue::Iterator it(response_headers); - !it.IsAtEnd(); - it.Advance()) { - std::string value; - CHECK(it.value().GetAsString(&value)); - out->response_headers->AddHeader(it.key() + " : " + value); - } - } - return true; -} - } // namespace mate diff --git a/atom/common/native_mate_converters/net_converter.h b/atom/common/native_mate_converters/net_converter.h index f251da8c5c8a..b11c55929b98 100644 --- a/atom/common/native_mate_converters/net_converter.h +++ b/atom/common/native_mate_converters/net_converter.h @@ -5,7 +5,6 @@ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_ -#include "atom/browser/net/atom_network_delegate.h" #include "base/memory/ref_counted.h" #include "native_mate/converter.h" @@ -35,13 +34,6 @@ struct Converter> { const scoped_refptr& val); }; -template<> -struct Converter { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - atom::AtomNetworkDelegate::BlockingResponse* out); -}; - } // namespace mate #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_