Fixing cpplint issues.

This commit is contained in:
ali.ibrahim 2016-09-29 11:31:08 +02:00
parent 08947682b0
commit 0588435882
6 changed files with 83 additions and 100 deletions

View file

@ -4,8 +4,8 @@
#include "atom/browser/api/atom_api_net.h" #include "atom/browser/api/atom_api_net.h"
#include "atom/browser/api/atom_api_url_request.h" #include "atom/browser/api/atom_api_url_request.h"
#include "native_mate/dictionary.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace atom { namespace atom {
@ -50,7 +50,6 @@ using atom::api::URLRequest;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused, void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) { v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
URLRequest::SetConstructor(isolate, base::Bind(URLRequest::New)); URLRequest::SetConstructor(isolate, base::Bind(URLRequest::New));
@ -58,9 +57,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("net", Net::Create(isolate)); dict.Set("net", Net::Create(isolate));
dict.Set("Net", Net::GetConstructor(isolate)->GetFunction()); dict.Set("Net", Net::GetConstructor(isolate)->GetFunction());
} }
} // namespace } // namespace
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize) NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize)

View file

@ -12,20 +12,18 @@ namespace atom {
namespace api { namespace api {
class Net : public mate::EventEmitter<Net> { class Net : public mate::EventEmitter<Net> {
public:
public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate); static v8::Local<v8::Value> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
v8::Local<v8::Value> URLRequest(v8::Isolate* isolate); v8::Local<v8::Value> URLRequest(v8::Isolate* isolate);
protected: protected:
Net(v8::Isolate* isolate); explicit Net(v8::Isolate* isolate);
~Net() override; ~Net() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(Net); DISALLOW_COPY_AND_ASSIGN(Net);
}; };
@ -34,4 +32,4 @@ private:
} // namespace atom } // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_NET_H_ #endif // ATOM_BROWSER_API_ATOM_API_NET_H_

View file

@ -2,31 +2,24 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/browser/api/atom_api_url_request.h" #include <string>
#include "atom/browser/api/atom_api_session.h" #include "atom/browser/api/atom_api_session.h"
#include "atom/browser/api/atom_api_url_request.h"
#include "native_mate/dictionary.h"
#include "atom/browser/net/atom_url_request.h" #include "atom/browser/net/atom_url_request.h"
#include "atom/common/node_includes.h" #include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/net_converter.h" #include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/callback.h" #include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace {
const char* const kResponse = "response";
const char* const kData = "data";
const char* const kEnd = "end";
}
namespace mate { namespace mate {
template<> template<>
struct Converter<scoped_refptr<const net::HttpResponseHeaders>> { struct Converter<scoped_refptr<const net::HttpResponseHeaders>> {
static v8::Local<v8::Value> ToV8( static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate, v8::Isolate* isolate,
scoped_refptr<const net::HttpResponseHeaders> val) { scoped_refptr<const net::HttpResponseHeaders> val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
if (val) { if (val) {
size_t iter = 0; size_t iter = 0;
@ -34,7 +27,7 @@ struct Converter<scoped_refptr<const net::HttpResponseHeaders>> {
std::string value; std::string value;
while (val->EnumerateHeaderLines(&iter, &name, &value)) { while (val->EnumerateHeaderLines(&iter, &name, &value)) {
dict.Set(name, value); dict.Set(name, value);
} }
} }
return dict.GetHandle(); return dict.GetHandle();
} }
@ -43,29 +36,27 @@ struct Converter<scoped_refptr<const net::HttpResponseHeaders>> {
template<> template<>
struct Converter<scoped_refptr<const net::IOBufferWithSize>> { struct Converter<scoped_refptr<const net::IOBufferWithSize>> {
static v8::Local<v8::Value> ToV8( static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate, v8::Isolate* isolate,
scoped_refptr<const net::IOBufferWithSize> buffer) { scoped_refptr<const net::IOBufferWithSize> buffer) {
return node::Buffer::Copy(isolate, return node::Buffer::Copy(isolate,
buffer->data(), buffer->data(),
buffer->size()).ToLocalChecked(); buffer->size()).ToLocalChecked();
} }
static bool FromV8( static bool FromV8(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
scoped_refptr<const net::IOBufferWithSize>* out) { scoped_refptr<const net::IOBufferWithSize>* out) {
auto size = node::Buffer::Length(val); auto size = node::Buffer::Length(val);
if (size == 0) { if (size == 0) {
// Support conversoin from empty buffer. A use case is // Support conversoin from empty buffer. A use case is
// a GET request without body. // a GET request without body.
// Since zero-sized IOBuffer(s) are not supported, we set the // Since zero-sized IOBuffer(s) are not supported, we set the
// out pointer to null. // out pointer to null.
*out = nullptr; *out = nullptr;
return true; return true;
} }
auto data = node::Buffer::Data(val); auto data = node::Buffer::Data(val);
if (!data) { if (!data) {
// This is an error as size is positif but data is null. // This is an error as size is positif but data is null.
@ -86,9 +77,9 @@ struct Converter<scoped_refptr<const net::IOBufferWithSize>> {
} }
}; };
} } // namespace mate
namespace atom {
namespace atom {
namespace api { namespace api {
URLRequest::URLRequest(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) URLRequest::URLRequest(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
@ -101,7 +92,6 @@ URLRequest::~URLRequest() {
// static // static
mate::WrappableBase* URLRequest::New(mate::Arguments* args) { mate::WrappableBase* URLRequest::New(mate::Arguments* args) {
v8::Local<v8::Object> options; v8::Local<v8::Object> options;
args->GetNext(&options); args->GetNext(&options);
mate::Dictionary dict(args->isolate(), options); mate::Dictionary dict(args->isolate(), options);
@ -122,7 +112,7 @@ mate::WrappableBase* URLRequest::New(mate::Arguments* args) {
method, method,
url, url,
weak_ptr); weak_ptr);
api_url_request->atom_request_ = atom_url_request; api_url_request->atom_request_ = atom_url_request;
return api_url_request; return api_url_request;
@ -146,15 +136,12 @@ void URLRequest::BuildPrototype(v8::Isolate* isolate,
.SetProperty("rawResponseHeaders", &URLRequest::RawResponseHeaders) .SetProperty("rawResponseHeaders", &URLRequest::RawResponseHeaders)
.SetProperty("httpVersionMajor", &URLRequest::ResponseHttpVersionMajor) .SetProperty("httpVersionMajor", &URLRequest::ResponseHttpVersionMajor)
.SetProperty("httpVersionMinor", &URLRequest::ResponseHttpVersionMinor); .SetProperty("httpVersionMinor", &URLRequest::ResponseHttpVersionMinor);
} }
bool URLRequest::Write( bool URLRequest::Write(
scoped_refptr<const net::IOBufferWithSize> buffer, scoped_refptr<const net::IOBufferWithSize> buffer,
bool is_last) { bool is_last) {
return atom_request_->Write(buffer, is_last); return atom_request_->Write(buffer, is_last);
} }
@ -191,7 +178,7 @@ void URLRequest::OnAuthenticationRequired(
auth_info.get(), auth_info.get(),
base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_)); base::Bind(&AtomURLRequest::PassLoginInformation, atom_request_));
} }
void URLRequest::OnResponseStarted() { void URLRequest::OnResponseStarted() {
Emit("response"); Emit("response");
@ -202,7 +189,6 @@ void URLRequest::OnResponseData(
if (!buffer || !buffer->data() || !buffer->size()) { if (!buffer || !buffer->data() || !buffer->size()) {
return; return;
} }
EmitResponseEvent("data", buffer); EmitResponseEvent("data", buffer);
} }
@ -234,7 +220,7 @@ std::string URLRequest::StatusMessage() const {
scoped_refptr<const net::HttpResponseHeaders> scoped_refptr<const net::HttpResponseHeaders>
URLRequest::RawResponseHeaders() const { URLRequest::RawResponseHeaders() const {
return atom_request_->GetResponseHeaders(); return atom_request_->GetResponseHeaders();
} }
uint32_t URLRequest::ResponseHttpVersionMajor() const { uint32_t URLRequest::ResponseHttpVersionMajor() const {
@ -261,6 +247,6 @@ void URLRequest::unpin() {
wrapper_.Reset(); wrapper_.Reset();
} }
} // namespace mate } // namespace api
} // namepsace mate } // namespace atom

View file

@ -6,10 +6,11 @@
#define ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_ #define ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_
#include <array> #include <array>
#include <string>
#include "atom/browser/api/trackable_object.h" #include "atom/browser/api/trackable_object.h"
#include "native_mate/handle.h" #include "native_mate/handle.h"
#include "net/url_request/url_request_context.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/url_request/url_request_context.h"
namespace atom { namespace atom {
@ -22,18 +23,19 @@ class URLRequest : public mate::EventEmitter<URLRequest> {
public: public:
static mate::WrappableBase* New(mate::Arguments* args); static mate::WrappableBase* New(mate::Arguments* args);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(
v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
protected: protected:
URLRequest(v8::Isolate* isolate, explicit URLRequest(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper); v8::Local<v8::Object> wrapper);
~URLRequest() override; ~URLRequest() override;
private: private:
bool Write(scoped_refptr<const net::IOBufferWithSize> buffer, bool Write(scoped_refptr<const net::IOBufferWithSize> buffer,
bool is_last); bool is_last);
void Abort(); void Abort();
bool SetExtraHeader(const std::string& name, const std::string& value); bool SetExtraHeader(const std::string& name, const std::string& value);
void RemoveExtraHeader(const std::string& name); void RemoveExtraHeader(const std::string& name);
@ -55,7 +57,7 @@ private:
template <typename ... ArgTypes> template <typename ... ArgTypes>
std::array<v8::Local<v8::Value>, sizeof...(ArgTypes)> std::array<v8::Local<v8::Value>, sizeof...(ArgTypes)>
BuildArgsArray(ArgTypes... args) const; BuildArgsArray(ArgTypes... args) const;
template <typename ... ArgTypes> template <typename ... ArgTypes>
@ -70,7 +72,6 @@ private:
scoped_refptr<AtomURLRequest> atom_request_; scoped_refptr<AtomURLRequest> atom_request_;
v8::Global<v8::Object> wrapper_; v8::Global<v8::Object> wrapper_;
base::WeakPtrFactory<URLRequest> weak_ptr_factory_; base::WeakPtrFactory<URLRequest> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequest); DISALLOW_COPY_AND_ASSIGN(URLRequest);
}; };
@ -107,8 +108,8 @@ void URLRequest::EmitResponseEvent(ArgTypes... args) {
} // namepsace api } // namespace api
} // namepsace atom } // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_ #endif // ATOM_BROWSER_API_ATOM_API_URL_REQUEST_H_

View file

@ -3,19 +3,21 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/browser/net/atom_url_request.h" #include <string>
#include "atom/browser/api/atom_api_url_request.h" #include "atom/browser/api/atom_api_url_request.h"
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/atom_url_request.h"
#include "base/callback.h" #include "base/callback.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "net/base/io_buffer.h"
#include "net/base/elements_upload_data_stream.h" #include "net/base/elements_upload_data_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/upload_bytes_element_reader.h" #include "net/base/upload_bytes_element_reader.h"
namespace { namespace {
const int kBufferSize = 4096; const int kBufferSize = 4096;
} // namespace } // namespace
namespace atom { namespace atom {
@ -23,7 +25,7 @@ namespace internal {
class UploadOwnedIOBufferElementReader : public net::UploadBytesElementReader { class UploadOwnedIOBufferElementReader : public net::UploadBytesElementReader {
public: public:
explicit UploadOwnedIOBufferElementReader( explicit UploadOwnedIOBufferElementReader(
scoped_refptr<const net::IOBufferWithSize> buffer) scoped_refptr<const net::IOBufferWithSize> buffer)
: net::UploadBytesElementReader(buffer->data(), buffer->size()) : net::UploadBytesElementReader(buffer->data(), buffer->size())
@ -39,18 +41,18 @@ public:
return new UploadOwnedIOBufferElementReader(std::move(buffer)); return new UploadOwnedIOBufferElementReader(std::move(buffer));
} }
private: private:
scoped_refptr<const net::IOBuffer> buffer_; scoped_refptr<const net::IOBuffer> buffer_;
DISALLOW_COPY_AND_ASSIGN(UploadOwnedIOBufferElementReader); DISALLOW_COPY_AND_ASSIGN(UploadOwnedIOBufferElementReader);
}; };
} } // namespace internal
AtomURLRequest::AtomURLRequest(base::WeakPtr<api::URLRequest> delegate) AtomURLRequest::AtomURLRequest(base::WeakPtr<api::URLRequest> delegate)
: delegate_(delegate) : delegate_(delegate)
, response_read_buffer_(new net::IOBuffer(kBufferSize)) , response_read_buffer_(new net::IOBuffer(kBufferSize))
, is_chunked_upload_(is_chunked_upload_) { , is_chunked_upload_(false) {
} }
AtomURLRequest::~AtomURLRequest() { AtomURLRequest::~AtomURLRequest() {
@ -73,7 +75,7 @@ scoped_refptr<AtomURLRequest> AtomURLRequest::Create(
DCHECK(context); DCHECK(context);
scoped_refptr<AtomURLRequest> atom_url_request = scoped_refptr<AtomURLRequest> atom_url_request =
new AtomURLRequest(delegate); new AtomURLRequest(delegate);
atom_url_request->request_ = context->CreateRequest(GURL(url), atom_url_request->request_ = context->CreateRequest(GURL(url),
@ -82,14 +84,13 @@ scoped_refptr<AtomURLRequest> AtomURLRequest::Create(
atom_url_request->request_->set_method(method); atom_url_request->request_->set_method(method);
return atom_url_request; return atom_url_request;
} }
bool AtomURLRequest::Write( bool AtomURLRequest::Write(
scoped_refptr<const net::IOBufferWithSize> buffer, scoped_refptr<const net::IOBufferWithSize> buffer,
bool is_last) { bool is_last) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return content::BrowserThread::PostTask( return content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE, content::BrowserThread::IO, FROM_HERE,
base::Bind(&AtomURLRequest::DoWriteBuffer, this, buffer, is_last)); base::Bind(&AtomURLRequest::DoWriteBuffer, this, buffer, is_last));
@ -154,7 +155,6 @@ void AtomURLRequest::DoWriteBuffer(
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (is_chunked_upload_) { if (is_chunked_upload_) {
// Chunked encoding case. // Chunked encoding case.
bool first_call = false; bool first_call = false;
@ -181,9 +181,7 @@ void AtomURLRequest::DoWriteBuffer(
if (first_call) if (first_call)
request_->Start(); request_->Start();
} } else {
else {
if (buffer) { if (buffer) {
// Handling potential empty buffers. // Handling potential empty buffers.
using internal::UploadOwnedIOBufferElementReader; using internal::UploadOwnedIOBufferElementReader;
@ -223,10 +221,10 @@ void AtomURLRequest::DoCancelAuth() const {
void AtomURLRequest::OnAuthRequired(net::URLRequest* request, void AtomURLRequest::OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) { net::AuthChallengeInfo* auth_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomURLRequest::InformDelegateAuthenticationRequired, base::Bind(&AtomURLRequest::InformDelegateAuthenticationRequired,
this, this,
scoped_refptr<net::AuthChallengeInfo>(auth_info))); scoped_refptr<net::AuthChallengeInfo>(auth_info)));
} }
@ -247,12 +245,13 @@ void AtomURLRequest::OnResponseStarted(net::URLRequest* request) {
base::Bind(&AtomURLRequest::InformDelegateResponseStarted, this)); base::Bind(&AtomURLRequest::InformDelegateResponseStarted, this));
ReadResponse(); ReadResponse();
} } else {
else {
auto error = net::ErrorToString(status.ToNetError()); auto error = net::ErrorToString(status.ToNetError());
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomURLRequest::InformDelegateErrorOccured, this, std::move(error))); base::Bind(&AtomURLRequest::InformDelegateErrorOccured,
this,
std::move(error)));
} }
} }
@ -264,10 +263,10 @@ void AtomURLRequest::ReadResponse() {
// completed immediately, without trying to read any data back (all we care // completed immediately, without trying to read any data back (all we care
// about is the response code and headers, which we already have). // about is the response code and headers, which we already have).
int bytes_read = 0; int bytes_read = 0;
if (request_->status().is_success() if (request_->status().is_success()
/* TODO && (request_type_ != URLFetcher::HEAD)*/) /* TODO && (request_type_ != URLFetcher::HEAD)*/)
if (!request_->Read(response_read_buffer_.get(), kBufferSize, &bytes_read)) if (!request_->Read(response_read_buffer_.get(), kBufferSize, &bytes_read))
bytes_read = -1; bytes_read = -1;
OnReadCompleted(request_.get(), bytes_read); OnReadCompleted(request_.get(), bytes_read);
} }
@ -284,7 +283,9 @@ void AtomURLRequest::OnReadCompleted(net::URLRequest* request,
auto error = net::ErrorToString(status.ToNetError()); auto error = net::ErrorToString(status.ToNetError());
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomURLRequest::InformDelegateErrorOccured, this, std::move(error))); base::Bind(&AtomURLRequest::InformDelegateErrorOccured,
this,
std::move(error)));
break; break;
} }
@ -295,15 +296,13 @@ void AtomURLRequest::OnReadCompleted(net::URLRequest* request,
} while (request_->Read(response_read_buffer_.get(), } while (request_->Read(response_read_buffer_.get(),
kBufferSize, kBufferSize,
&bytes_read)); &bytes_read));
if (!status.is_io_pending() if (!status.is_io_pending()
/* TODO || request_type_ == URLFetcher::HEAD*/ ) /* TODO || request_type_ == URLFetcher::HEAD*/ )
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomURLRequest::InformDelegateResponseCompleted, this)); base::Bind(&AtomURLRequest::InformDelegateResponseCompleted, this));
} }
bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) { bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) {
@ -361,4 +360,4 @@ void AtomURLRequest::InformDelegateErrorOccured(
} }
} // namespace atom } // namespace atom

View file

@ -6,9 +6,11 @@
#ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_ #ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_
#define ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_ #define ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_
#include <string>
#include <vector>
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "net/url_request/url_request.h"
#include "net/base/chunked_upload_data_stream.h" #include "net/base/chunked_upload_data_stream.h"
#include "net/url_request/url_request.h"
namespace net { namespace net {
@ -27,7 +29,7 @@ class URLRequest;
class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>, class AtomURLRequest : public base::RefCountedThreadSafe<AtomURLRequest>,
public net::URLRequest::Delegate { public net::URLRequest::Delegate {
public: public:
static scoped_refptr<AtomURLRequest> Create( static scoped_refptr<AtomURLRequest> Create(
AtomBrowserContext* browser_context, AtomBrowserContext* browser_context,
const std::string& method, const std::string& method,
@ -44,15 +46,15 @@ public:
const base::string16& password) const; const base::string16& password) const;
scoped_refptr<const net::HttpResponseHeaders> GetResponseHeaders() const; scoped_refptr<const net::HttpResponseHeaders> GetResponseHeaders() const;
protected: protected:
// Overrides of net::URLRequest::Delegate // Overrides of net::URLRequest::Delegate
virtual void OnAuthRequired(net::URLRequest* request, void OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) override; net::AuthChallengeInfo* auth_info) override;
virtual void OnResponseStarted(net::URLRequest* request) override; void OnResponseStarted(net::URLRequest* request) override;
virtual void OnReadCompleted(net::URLRequest* request, void OnReadCompleted(net::URLRequest* request,
int bytes_read) override; int bytes_read) override;
private: private:
friend class base::RefCountedThreadSafe<AtomURLRequest>; friend class base::RefCountedThreadSafe<AtomURLRequest>;
void DoWriteBuffer(scoped_refptr<const net::IOBufferWithSize> buffer, void DoWriteBuffer(scoped_refptr<const net::IOBufferWithSize> buffer,
bool is_last); bool is_last);
@ -72,7 +74,7 @@ private:
void InformDelegateResponseCompleted() const; void InformDelegateResponseCompleted() const;
void InformDelegateErrorOccured(const std::string& error) const; void InformDelegateErrorOccured(const std::string& error) const;
AtomURLRequest(base::WeakPtr<api::URLRequest> delegate); explicit AtomURLRequest(base::WeakPtr<api::URLRequest> delegate);
virtual ~AtomURLRequest(); virtual ~AtomURLRequest();
base::WeakPtr<api::URLRequest> delegate_; base::WeakPtr<api::URLRequest> delegate_;
@ -81,15 +83,14 @@ private:
bool is_chunked_upload_; bool is_chunked_upload_;
std::unique_ptr<net::ChunkedUploadDataStream> chunked_stream_; std::unique_ptr<net::ChunkedUploadDataStream> chunked_stream_;
std::unique_ptr<net::ChunkedUploadDataStream::Writer> chunked_stream_writer_; std::unique_ptr<net::ChunkedUploadDataStream::Writer> chunked_stream_writer_;
std::vector<std::unique_ptr<net::UploadElementReader>>
std::vector<std::unique_ptr<net::UploadElementReader>>upload_element_readers_; upload_element_readers_;
scoped_refptr<net::IOBuffer> response_read_buffer_; scoped_refptr<net::IOBuffer> response_read_buffer_;
scoped_refptr<net::HttpResponseHeaders> response_headers_; scoped_refptr<net::HttpResponseHeaders> response_headers_;
DISALLOW_COPY_AND_ASSIGN(AtomURLRequest); DISALLOW_COPY_AND_ASSIGN(AtomURLRequest);
}; };
} // namespace atom } // namespace atom
#endif // ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_ #endif // ATOM_BROWSER_NET_ATOM_URL_REQUEST_H_