Indenting stuff

This commit is contained in:
Samuel Attard 2017-07-27 11:52:19 +10:00
parent ed717a9b45
commit f385e19594
4 changed files with 25 additions and 20 deletions

View file

@ -21,7 +21,7 @@ struct Converter<base::Time> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Time& val) {
v8::MaybeLocal<v8::Value> date = v8::Date::New(
isolate->GetCurrentContext(), val.ToJsTime());
isolate->GetCurrentContext(), val.ToJsTime());
if (date.IsEmpty())
return v8::Null(isolate);
else
@ -49,11 +49,12 @@ void AutoUpdater::OnError(const std::string& message) {
v8::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
mate::EmitEvent(
isolate(),
GetWrapper(),
"error",
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
message);
isolate(),
GetWrapper(),
"error",
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
// Message is also emitted to keep compatibility with old code.
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 base::Time& release_date,
const std::string& url) {
Emit("update-downloaded", release_notes, release_name, release_date,
url, base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this)));
Emit("update-downloaded", release_notes, release_name, release_date, url,
// Keep compatibility with old APIs.
base::Bind(&AutoUpdater::QuitAndInstall, base::Unretained(this)));
}
void AutoUpdater::OnWindowAllClosed() {
@ -122,13 +124,13 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
// static
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"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
}
} // namespace api

View file

@ -32,8 +32,8 @@ class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
// Delegate implementations.
void OnError(const std::string& error) override;
void OnError(const std::string& message,
const int code, const std::string& domain);
void OnError(const std::string& message, const int code,
const std::string& domain);
void OnCheckingForUpdate() override;
void OnUpdateAvailable() override;
void OnUpdateNotAvailable() override;

View file

@ -22,8 +22,8 @@ class Delegate {
// An error happened.
virtual void OnError(const std::string& error) {}
virtual void OnError(const std::string& error,
const int code, const std::string& domain) {}
virtual void OnError(const std::string& error, const int code,
const std::string& domain) {}
// Checking to see if there is an update
virtual void OnCheckingForUpdate() {}

View file

@ -104,7 +104,8 @@ void AutoUpdater::CheckForUpdates() {
delegate->OnUpdateNotAvailable();
}
} error:^(NSError *error) {
NSMutableString *failureString = [NSMutableString stringWithString:error.localizedDescription];
NSMutableString *failureString =
[NSMutableString stringWithString:error.localizedDescription];
if (error.localizedFailureReason) {
[failureString appendString:@": "];
[failureString appendString:error.localizedFailureReason];
@ -115,7 +116,8 @@ void AutoUpdater::CheckForUpdates() {
[failureString appendString:@" "];
[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) {
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
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 {
if (delegate)