Refactoring: use C++11 class member variable initialization

This commit is contained in:
Milan Burda 2018-05-22 00:18:38 +02:00
parent ee57c95aa6
commit 2337237d58
94 changed files with 218 additions and 377 deletions

View file

@ -51,8 +51,7 @@ namespace api {
BrowserView::BrowserView(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
const mate::Dictionary& options)
: api_web_contents_(nullptr) {
const mate::Dictionary& options) {
Init(isolate, wrapper, options);
}

View file

@ -59,7 +59,7 @@ class BrowserView : public mate::TrackableObject<BrowserView> {
v8::Local<v8::Value> GetWebContents();
v8::Global<v8::Value> web_contents_;
class WebContents* api_web_contents_;
class WebContents* api_web_contents_ = nullptr;
std::unique_ptr<NativeBrowserView> view_;

View file

@ -26,7 +26,7 @@ namespace atom {
namespace api {
Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
: web_contents_(web_contents), previous_request_id_(0) {
: web_contents_(web_contents) {
Init(isolate);
}

View file

@ -63,7 +63,7 @@ class Debugger : public mate::TrackableObject<Debugger>,
scoped_refptr<content::DevToolsAgentHost> agent_host_;
PendingRequestMap pending_requests_;
int previous_request_id_;
int previous_request_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(Debugger);
};

View file

@ -20,7 +20,7 @@ namespace atom {
namespace api {
Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
: model_(new AtomMenuModel(this)), parent_(nullptr) {
: model_(new AtomMenuModel(this)) {
InitWith(isolate, wrapper);
model_->AddObserver(this);
}

View file

@ -62,7 +62,7 @@ class Menu : public mate::TrackableObject<Menu>,
virtual void ClosePopupAt(int32_t window_id) = 0;
std::unique_ptr<AtomMenuModel> model_;
Menu* parent_;
Menu* parent_ = nullptr;
// Observable:
void OnMenuWillClose() override;

View file

@ -336,13 +336,7 @@ struct WebContents::FrameDispatchHelper {
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type)
: content::WebContentsObserver(web_contents),
embedder_(nullptr),
zoom_controller_(nullptr),
type_(type),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
: content::WebContentsObserver(web_contents), type_(type) {
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
if (type == REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
@ -356,13 +350,8 @@ WebContents::WebContents(v8::Isolate* isolate,
}
}
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
: embedder_(nullptr),
zoom_controller_(nullptr),
type_(BROWSER_WINDOW),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options) {
// Read options.
options.Get("backgroundThrottling", &background_throttling_);

View file

@ -437,22 +437,22 @@ class WebContents : public mate::TrackableObject<WebContents>,
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
// The host webcontents that may contain this webcontents.
WebContents* embedder_;
WebContents* embedder_ = nullptr;
// The zoom controller for this webContents.
WebContentsZoomController* zoom_controller_;
WebContentsZoomController* zoom_controller_ = nullptr;
// The type of current WebContents.
Type type_;
Type type_ = BROWSER_WINDOW;
// Request id used for findInPage request.
uint32_t request_id_;
uint32_t request_id_ = 0;
// Whether background throttling is disabled.
bool background_throttling_;
bool background_throttling_ = true;
// Whether to enable devtools.
bool enable_devtools_;
bool enable_devtools_ = true;
// Observers of this WebContents.
base::ObserverList<ExtendedWebContentsObserver> observers_;

View file

@ -12,7 +12,7 @@
namespace mate {
Event::Event(v8::Isolate* isolate) : sender_(nullptr), message_(nullptr) {
Event::Event(v8::Isolate* isolate) {
Init(isolate);
}

View file

@ -44,8 +44,8 @@ class Event : public Wrappable<Event>, public content::WebContentsObserver {
private:
// Replyer for the synchronous messages.
content::RenderFrameHost* sender_;
IPC::Message* message_;
content::RenderFrameHost* sender_ = nullptr;
IPC::Message* message_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(Event);
};

View file

@ -28,8 +28,7 @@ class IDUserData : public base::SupportsUserData::Data {
} // namespace
TrackableObjectBase::TrackableObjectBase()
: weak_map_id_(0), weak_factory_(this) {
TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) {
atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
GetDestroyClosure());
}
@ -54,8 +53,8 @@ void TrackableObjectBase::AttachAsUserData(base::SupportsUserData* wrapped) {
int32_t TrackableObjectBase::GetIDFromWrappedClass(
base::SupportsUserData* wrapped) {
if (wrapped) {
auto* id = static_cast<IDUserData*>(
wrapped->GetUserData(kTrackedObjectKey));
auto* id =
static_cast<IDUserData*>(wrapped->GetUserData(kTrackedObjectKey));
if (id)
return *id;
}

View file

@ -39,7 +39,7 @@ class TrackableObjectBase {
// Returns a closure that can destroy the native class.
base::OnceClosure GetDestroyClosure();
int32_t weak_map_id_;
int32_t weak_map_id_ = 0;
private:
void Destroy();