Indenting stuff
This commit is contained in:
parent
ed717a9b45
commit
f385e19594
4 changed files with 25 additions and 20 deletions
|
@ -21,7 +21,7 @@ struct Converter<base::Time> {
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
const base::Time& val) {
|
const base::Time& val) {
|
||||||
v8::MaybeLocal<v8::Value> date = v8::Date::New(
|
v8::MaybeLocal<v8::Value> date = v8::Date::New(
|
||||||
isolate->GetCurrentContext(), val.ToJsTime());
|
isolate->GetCurrentContext(), val.ToJsTime());
|
||||||
if (date.IsEmpty())
|
if (date.IsEmpty())
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
else
|
else
|
||||||
|
@ -49,11 +49,12 @@ void AutoUpdater::OnError(const std::string& message) {
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
||||||
mate::EmitEvent(
|
mate::EmitEvent(
|
||||||
isolate(),
|
isolate(),
|
||||||
GetWrapper(),
|
GetWrapper(),
|
||||||
"error",
|
"error",
|
||||||
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
|
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
|
||||||
message);
|
// Message is also emitted to keep compatibility with old code.
|
||||||
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::OnError(const std::string& message,
|
void AutoUpdater::OnError(const std::string& message,
|
||||||
|
@ -89,8 +90,9 @@ void AutoUpdater::OnUpdateDownloaded(const std::string& release_notes,
|
||||||
const std::string& release_name,
|
const std::string& release_name,
|
||||||
const base::Time& release_date,
|
const base::Time& release_date,
|
||||||
const std::string& url) {
|
const std::string& url) {
|
||||||
Emit("update-downloaded", release_notes, release_name, release_date,
|
Emit("update-downloaded", release_notes, release_name, release_date, url,
|
||||||
url, base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this)));
|
// Keep compatibility with old APIs.
|
||||||
|
base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::OnWindowAllClosed() {
|
void AutoUpdater::OnWindowAllClosed() {
|
||||||
|
@ -122,13 +124,13 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AutoUpdater::BuildPrototype(
|
void AutoUpdater::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
|
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
|
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
|
||||||
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
|
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
|
||||||
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
|
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
|
||||||
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
|
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -32,8 +32,8 @@ class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
|
||||||
|
|
||||||
// Delegate implementations.
|
// Delegate implementations.
|
||||||
void OnError(const std::string& error) override;
|
void OnError(const std::string& error) override;
|
||||||
void OnError(const std::string& message,
|
void OnError(const std::string& message, const int code,
|
||||||
const int code, const std::string& domain);
|
const std::string& domain);
|
||||||
void OnCheckingForUpdate() override;
|
void OnCheckingForUpdate() override;
|
||||||
void OnUpdateAvailable() override;
|
void OnUpdateAvailable() override;
|
||||||
void OnUpdateNotAvailable() override;
|
void OnUpdateNotAvailable() override;
|
||||||
|
|
|
@ -22,8 +22,8 @@ class Delegate {
|
||||||
// An error happened.
|
// An error happened.
|
||||||
virtual void OnError(const std::string& error) {}
|
virtual void OnError(const std::string& error) {}
|
||||||
|
|
||||||
virtual void OnError(const std::string& error,
|
virtual void OnError(const std::string& error, const int code,
|
||||||
const int code, const std::string& domain) {}
|
const std::string& domain) {}
|
||||||
|
|
||||||
// Checking to see if there is an update
|
// Checking to see if there is an update
|
||||||
virtual void OnCheckingForUpdate() {}
|
virtual void OnCheckingForUpdate() {}
|
||||||
|
|
|
@ -104,7 +104,8 @@ void AutoUpdater::CheckForUpdates() {
|
||||||
delegate->OnUpdateNotAvailable();
|
delegate->OnUpdateNotAvailable();
|
||||||
}
|
}
|
||||||
} error:^(NSError *error) {
|
} error:^(NSError *error) {
|
||||||
NSMutableString *failureString = [NSMutableString stringWithString:error.localizedDescription];
|
NSMutableString *failureString =
|
||||||
|
[NSMutableString stringWithString:error.localizedDescription];
|
||||||
if (error.localizedFailureReason) {
|
if (error.localizedFailureReason) {
|
||||||
[failureString appendString:@": "];
|
[failureString appendString:@": "];
|
||||||
[failureString appendString:error.localizedFailureReason];
|
[failureString appendString:error.localizedFailureReason];
|
||||||
|
@ -115,7 +116,8 @@ void AutoUpdater::CheckForUpdates() {
|
||||||
[failureString appendString:@" "];
|
[failureString appendString:@" "];
|
||||||
[failureString appendString:error.localizedRecoverySuggestion];
|
[failureString appendString:error.localizedRecoverySuggestion];
|
||||||
}
|
}
|
||||||
delegate->OnError(base::SysNSStringToUTF8(failureString), error.code, base::SysNSStringToUTF8(error.domain));
|
delegate->OnError(base::SysNSStringToUTF8(failureString), error.code,
|
||||||
|
base::SysNSStringToUTF8(error.domain));
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +126,8 @@ void AutoUpdater::QuitAndInstall() {
|
||||||
if (g_update_available) {
|
if (g_update_available) {
|
||||||
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
|
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
|
||||||
if (delegate)
|
if (delegate)
|
||||||
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription), error.code, base::SysNSStringToUTF8(error.domain));
|
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription),
|
||||||
|
error.code, base::SysNSStringToUTF8(error.domain));
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
if (delegate)
|
if (delegate)
|
||||||
|
|
Loading…
Reference in a new issue