-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
net module #7577
Changes from 30 commits
e8d4abe
7521aee
81eab98
2d9d4af
2b3b41d
f7525d7
fcaf9cb
9498a57
cbbc437
0894768
0588435
42adb2a
bde30b9
ec1fc5a
e472d11
a655cca
8c5751e
dcffb51
42bae9d
b57ffbf
046f48d
9b94dfc
4eb9fc1
b731ca5
a5c508d
bd5e622
d21def7
ae1c33b
16069cd
b290415
6f5b0a2
de29f2d
9cc8bfa
4347ce4
c0c9e3a
ac9e6ed
0e13b8d
c6ae27c
9b4e9c6
c198828
43113fc
9bddc2c
f651b21
5cd20a8
0d82fbc
3b620b8
6e5951b
fddbde2
7549adc
7f8b180
fdfa0f4
69790bd
9f15191
8c19d3b
7c17aeb
0c44d19
61278f9
6d7f179
b44d529
bdb3f4d
e9db926
6d92457
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 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/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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
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) |
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_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is year 2016 :)