diff --git a/atom.gyp b/atom.gyp index 3719bf47af..ee5a10a7d4 100644 --- a/atom.gyp +++ b/atom.gyp @@ -99,6 +99,8 @@ 'browser/native_window_observer.h', 'browser/net/atom_url_request_job_factory.cc', 'browser/net/atom_url_request_job_factory.h', + 'browser/net/url_request_string_job.cc', + 'browser/net/url_request_string_job.h', 'browser/ui/accelerator_util.cc', 'browser/ui/accelerator_util.h', 'browser/ui/accelerator_util_mac.mm', diff --git a/browser/api/atom_api_protocol.cc b/browser/api/atom_api_protocol.cc index 9ed2586627..91f47b4295 100644 --- a/browser/api/atom_api_protocol.cc +++ b/browser/api/atom_api_protocol.cc @@ -7,12 +7,12 @@ #include "base/memory/weak_ptr.h" #include "browser/atom_browser_context.h" #include "browser/net/atom_url_request_job_factory.h" +#include "browser/net/url_request_string_job.h" #include "content/public/browser/browser_thread.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_error_job.h" #include "net/url_request/url_request_file_job.h" -#include "net/url_request/url_request_simple_job.h" #include "vendor/node/src/node.h" #include "vendor/node/src/node_internals.h" @@ -64,38 +64,6 @@ AtomURLRequestJobFactory* GetRequestJobFactory() { GetRequestContext()->GetURLRequestContext()->job_factory())); } -class URLRequestStringJob : public net::URLRequestSimpleJob { - public: - URLRequestStringJob(net::URLRequest* request, - net::NetworkDelegate* network_delegate, - const std::string& mime_type, - const std::string& charset, - const std::string& data) - : net::URLRequestSimpleJob(request, network_delegate), - mime_type_(mime_type), - charset_(charset), - data_(data) { - } - - // URLRequestSimpleJob: - virtual int GetData(std::string* mime_type, - std::string* charset, - std::string* data, - const net::CompletionCallback& callback) const OVERRIDE { - *mime_type = mime_type_; - *charset = charset_; - *data = data_; - return net::OK; - } - - private: - std::string mime_type_; - std::string charset_; - std::string data_; - - DISALLOW_COPY_AND_ASSIGN(URLRequestStringJob); -}; - // Ask JS which type of job it wants, and then delegate corresponding methods. class AdapterRequestJob : public net::URLRequestJob { public: diff --git a/browser/net/url_request_string_job.cc b/browser/net/url_request_string_job.cc new file mode 100644 index 0000000000..4a0e3ada8c --- /dev/null +++ b/browser/net/url_request_string_job.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2013 GitHub, Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "browser/net/url_request_string_job.h" + +#include "net/base/net_errors.h" + +namespace atom { + +URLRequestStringJob::URLRequestStringJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const std::string& mime_type, + const std::string& charset, + const std::string& data) + : net::URLRequestSimpleJob(request, network_delegate), + mime_type_(mime_type), + charset_(charset), + data_(data) { +} + +int URLRequestStringJob::GetData( + std::string* mime_type, + std::string* charset, + std::string* data, + const net::CompletionCallback& callback) const { + *mime_type = mime_type_; + *charset = charset_; + *data = data_; + return net::OK; +} + +} // namespace atom diff --git a/browser/net/url_request_string_job.h b/browser/net/url_request_string_job.h new file mode 100644 index 0000000000..688f5f9b73 --- /dev/null +++ b/browser/net/url_request_string_job.h @@ -0,0 +1,36 @@ +// Copyright (c) 2013 GitHub, Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/url_request/url_request_simple_job.h" + +#ifndef ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_ +#define ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_ + +namespace atom { + +class URLRequestStringJob : public net::URLRequestSimpleJob { + public: + URLRequestStringJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const std::string& mime_type, + const std::string& charset, + const std::string& data); + + // URLRequestSimpleJob: + virtual int GetData(std::string* mime_type, + std::string* charset, + std::string* data, + const net::CompletionCallback& callback) const OVERRIDE; + + private: + std::string mime_type_; + std::string charset_; + std::string data_; + + DISALLOW_COPY_AND_ASSIGN(URLRequestStringJob); +}; + +} // namespace atom + +#endif // ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_