Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net module #7577

Merged
merged 62 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e8d4abe
Adding net module and URLRequest class.
Sep 15, 2016
7521aee
Implement URLRequest::Delegate, handle thread sync.
Sep 19, 2016
81eab98
Adding URLResponse to emit response events, implementing status code.
Sep 19, 2016
2d9d4af
Implementing URLRequest API, getting response body.
Sep 21, 2016
2b3b41d
Implementing authentication callback.
Sep 21, 2016
f7525d7
Adding support for POST requests.
Sep 26, 2016
fcaf9cb
Some code cleaning.
Sep 26, 2016
9498a57
Refactoring net module, adding a ClientRequest and IncomingMessage cl…
Sep 27, 2016
cbbc437
Adding support for upload chunked encoding.
Sep 27, 2016
0894768
Implementing abort workflow, emitting error events.
Sep 28, 2016
0588435
Fixing cpplint issues.
Sep 29, 2016
42adb2a
Fixing lint-js issues.
Sep 29, 2016
bde30b9
Adding some implementation comments. Enforcing Chromium coding conven…
Sep 30, 2016
ec1fc5a
Implementing error, close, finish, abort events management.
Oct 4, 2016
e472d11
Caching response headers so that AtomURLRequest can be freed after th…
Oct 4, 2016
a655cca
Request/Response state simplification. Removing redundant state flags.
Oct 4, 2016
8c5751e
Adding systematic checks on the atom_request_ pointer as it may be re…
Oct 4, 2016
dcffb51
Adding net module spec file skeleton.
Oct 5, 2016
42bae9d
Making the HTTP response a full-fledged Readable stream.
Oct 6, 2016
b57ffbf
Temporary fix for the post data test.
Oct 6, 2016
046f48d
Fixing build on Linux
Oct 6, 2016
9b94dfc
Adding basic http tests, fixing issues in ClientRequest constructor.
Oct 7, 2016
4eb9fc1
Adding chunked uploading test.
Oct 7, 2016
b731ca5
Adding HTTP request headers manipulation tests.
Oct 10, 2016
a5c508d
Adding abort, webRequest interception and creation tests.
Oct 10, 2016
bd5e622
Adding request/response piping tests.
Oct 11, 2016
d21def7
Fixing various issues in tests.
Oct 11, 2016
ae1c33b
fixing linter issues.
Oct 12, 2016
16069cd
Commenting some test code.
Oct 12, 2016
b290415
Fixing build on Mac OS
Oct 12, 2016
6f5b0a2
Fixing code review issues: function call formatting, renaming JS memb…
Oct 13, 2016
de29f2d
Fixing build: removing constness on net::HttpResponseHeaders as other…
Oct 13, 2016
9cc8bfa
fixing space formatting issues.
Oct 14, 2016
4347ce4
Formatting C++ code using ClangFormat.
Oct 14, 2016
c0c9e3a
Formatting C++ code using ClangFormat.
Oct 14, 2016
ac9e6ed
Fixing a crash with pending URLRequests on shutdown.
Oct 14, 2016
0e13b8d
making the net module usable only after the ready event.
Oct 14, 2016
c6ae27c
Adding a stability test: non referenced, unused requests are collecte…
Oct 17, 2016
9b4e9c6
Making test code run directly in main browser context to avoid rpc pe…
Oct 17, 2016
c198828
Adding gc tests: fixing a memory leak with C++ URLRequest objects.
Oct 17, 2016
43113fc
Fixing net response objects being piped into writable streams test.
Oct 18, 2016
9bddc2c
Adding net documentation skeleton.
Oct 18, 2016
f651b21
Fixing net doc file name.
Oct 19, 2016
5cd20a8
Documenting net.ClientRequest
Oct 19, 2016
0d82fbc
Documenting net.IncomingMessage.
Oct 19, 2016
3b620b8
Documenting net module: various fixes.
Oct 19, 2016
6e5951b
Documenting net module: formatting.
Oct 19, 2016
fddbde2
Documenting net module: various fixes.
Oct 19, 2016
7549adc
Documenting net module: various fixes.
Oct 19, 2016
7f8b180
Fixing authentication cancel with null/undefined credentials.
Oct 20, 2016
fdfa0f4
Documenting the login event.
Oct 20, 2016
69790bd
Documenting ClientRequest constructor options.
Oct 20, 2016
9f15191
Formatting net documentation.
Oct 20, 2016
8c19d3b
Documenting net module: various fixes.
Oct 20, 2016
7c17aeb
Documenting net module: fixing linter issues.
Oct 20, 2016
0c44d19
net module: documenting the session property.
Oct 20, 2016
61278f9
Fixing code review issues.
Oct 25, 2016
6d7f179
Fixing code review issues: making delegate_ a raw pointer.
Oct 25, 2016
b44d529
Fixing code review issues: adding a partition options and making the …
Oct 25, 2016
bdb3f4d
Fixing code review issues: adding some test cases for partition/sessi…
Oct 25, 2016
e9db926
Fixing code review issues: fixing linter issues in spec file.
Oct 25, 2016
6d92457
Fixing code review issues: refactoring emit methods using CustomEmit.
Oct 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions atom/browser/api/atom_api_net.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) 2013 GitHub, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is year 2016 :)

// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/browser/api/atom_api_net.h"
#include "atom/browser/api/atom_api_url_request.h"
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"

namespace atom {

namespace api {

Net::Net(v8::Isolate* isolate) {
Init(isolate);
}

Net::~Net() {
}


// static
v8::Local<v8::Value> Net::Create(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new Net(isolate)).ToV8();
}

// static
void Net::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Net"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetProperty("URLRequest", &Net::URLRequest)
.SetMethod("_RequestGarbageCollectionForTesting",
&Net::RequestGarbageCollectionForTesting);
}

v8::Local<v8::Value> Net::URLRequest(v8::Isolate* isolate) {
return URLRequest::GetConstructor(isolate)->GetFunction();
}


void Net::RequestGarbageCollectionForTesting() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think atom_api_v8_util.cc is a better place to put this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi zcbenz,

Do we want to make it RequestGarbageCollectionForTesting public? I can use "RequestGarbageCollectionForTesting" instead of the underscored name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v8Util is a hidden module so you can use any meaningful name without worrying about adding underscore.

isolate()->RequestGarbageCollectionForTesting(
v8::Isolate::GarbageCollectionType::kFullGarbageCollection);
}


} // namespace api

} // namespace atom


namespace {

using atom::api::Net;
using atom::api::URLRequest;

void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();

URLRequest::SetConstructor(isolate, base::Bind(URLRequest::New));

mate::Dictionary dict(isolate, exports);
dict.Set("net", Net::Create(isolate));
dict.Set("Net", Net::GetConstructor(isolate)->GetFunction());
}

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize)
36 changes: 36 additions & 0 deletions atom/browser/api/atom_api_net.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#ifndef ATOM_BROWSER_API_ATOM_API_NET_H_
#define ATOM_BROWSER_API_ATOM_API_NET_H_

#include "atom/browser/api/event_emitter.h"

namespace atom {

namespace api {

class Net : public mate::EventEmitter<Net> {
public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate);

static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);

v8::Local<v8::Value> URLRequest(v8::Isolate* isolate);
protected:
explicit Net(v8::Isolate* isolate);
~Net() override;

private:
void RequestGarbageCollectionForTesting();
DISALLOW_COPY_AND_ASSIGN(Net);
};

} // namespace api

} // namespace atom


#endif // ATOM_BROWSER_API_ATOM_API_NET_H_
Loading