add protocol.RequestBuffer api
This commit is contained in:
parent
b19cfba98e
commit
9eac8ef266
9 changed files with 144 additions and 0 deletions
38
atom/browser/net/url_request_buffer_job.cc
Normal file
38
atom/browser/net/url_request_buffer_job.cc
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/net/url_request_buffer_job.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "net/base/net_errors.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
URLRequestBufferJob::URLRequestBufferJob(net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate,
|
||||
const std::string& mime_type,
|
||||
const std::string& charset,
|
||||
v8::Local<v8::Object> data)
|
||||
: net::URLRequestSimpleJob(request, network_delegate),
|
||||
mime_type_(mime_type),
|
||||
charset_(charset),
|
||||
buffer_data_(new base::RefCountedBytes()) {
|
||||
auto input = reinterpret_cast<const unsigned char*>(node::Buffer::Data(data));
|
||||
size_t length = node::Buffer::Length(data);
|
||||
buffer_data_->data().assign(input, input + length);
|
||||
}
|
||||
|
||||
int URLRequestBufferJob::GetRefCountedData(
|
||||
std::string* mime_type,
|
||||
std::string* charset,
|
||||
scoped_refptr<base::RefCountedMemory>* data,
|
||||
const net::CompletionCallback& callback) const {
|
||||
*mime_type = mime_type_;
|
||||
*charset = charset_;
|
||||
*data = buffer_data_;
|
||||
return net::OK;
|
||||
}
|
||||
|
||||
} // namespace atom
|
Loading…
Add table
Add a link
Reference in a new issue