]> khamidou — GitHub mirrors - electron.git/commitdiff
Separate URLRequestStringJob from atom_api_protocol.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 08:16:41 +0000 (16:16 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 30 Aug 2013 08:16:41 +0000 (16:16 +0800)
atom.gyp
browser/api/atom_api_protocol.cc
browser/net/url_request_string_job.cc [new file with mode: 0644]
browser/net/url_request_string_job.h [new file with mode: 0644]

index 3719bf47af7cda396bcbf6e73ce48a149b7ea770..ee5a10a7d4208d290c168f04810f441a057c44d7 100644 (file)
--- 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',
index 9ed2586627351980d2ddee9599e427dca1f9c055..91f47b4295928a2d20d5f71781631419799f2310 100644 (file)
@@ -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 (file)
index 0000000..4a0e3ad
--- /dev/null
@@ -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 (file)
index 0000000..688f5f9
--- /dev/null
@@ -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_