clang-format objc files (#12673)

This commit is contained in:
Shelley Vohr 2018-04-20 14:47:04 -04:00 committed by Charles Kerr
parent 94236bf4eb
commit 12a57ff1c2
54 changed files with 1298 additions and 1033 deletions

View file

@ -4,16 +4,16 @@
#include "atom/browser/auto_updater.h"
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
#import <ReactiveCocoa/RACCommand.h>
#import <ReactiveCocoa/RACSignal.h>
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
#import <Squirrel/Squirrel.h>
#include "atom/browser/browser.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/bind.h"
#include "base/time/time.h"
#include "base/strings/sys_string_conversions.h"
#include "base/time/time.h"
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
@ -31,7 +31,7 @@ namespace {
bool g_update_available = false;
std::string update_url_ = "";
} // namespace
} // namespace
std::string AutoUpdater::GetFeedURL() {
return update_url_;
@ -45,7 +45,9 @@ void AutoUpdater::SetFeedURL(mate::Arguments* args) {
std::string serverType = "default";
if (args->GetNext(&opts)) {
if (!opts.Get("url", &feed)) {
args->ThrowError("Expected options object to contain a 'url' string property in setFeedUrl call");
args->ThrowError(
"Expected options object to contain a 'url' string property in "
"setFeedUrl call");
return;
}
opts.Get("headers", &requestHeaders);
@ -57,10 +59,11 @@ void AutoUpdater::SetFeedURL(mate::Arguments* args) {
} else if (args->GetNext(&feed)) {
args->GetNext(&requestHeaders);
} else {
args->ThrowError("Expected an options object with a 'url' property to be provided");
args->ThrowError(
"Expected an options object with a 'url' property to be provided");
return;
}
Delegate* delegate = GetDelegate();
if (!delegate)
return;
@ -72,7 +75,7 @@ void AutoUpdater::SetFeedURL(mate::Arguments* args) {
for (const auto& it : requestHeaders) {
[urlRequest setValue:base::SysUTF8ToNSString(it.second)
forHTTPHeaderField:base::SysUTF8ToNSString(it.first)];
forHTTPHeaderField:base::SysUTF8ToNSString(it.first)];
}
if (g_updater)
@ -81,8 +84,10 @@ void AutoUpdater::SetFeedURL(mate::Arguments* args) {
// Initialize the SQRLUpdater.
@try {
if (serverType == "json") {
NSString* nsAppVersion = base::SysUTF8ToNSString(atom::Browser::Get()->GetVersion());
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest forVersion:nsAppVersion];
NSString* nsAppVersion =
base::SysUTF8ToNSString(atom::Browser::Get()->GetVersion());
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest
forVersion:nsAppVersion];
} else {
// default
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
@ -93,16 +98,16 @@ void AutoUpdater::SetFeedURL(mate::Arguments* args) {
}
[[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
subscribeNext:^(NSNumber *stateNumber) {
int state = [stateNumber integerValue];
// Dispatching the event on main thread.
dispatch_async(dispatch_get_main_queue(), ^{
if (state == SQRLUpdaterStateCheckingForUpdate)
delegate->OnCheckingForUpdate();
else if (state == SQRLUpdaterStateDownloadingUpdate)
delegate->OnUpdateAvailable();
});
}];
subscribeNext:^(NSNumber* stateNumber) {
int state = [stateNumber integerValue];
// Dispatching the event on main thread.
dispatch_async(dispatch_get_main_queue(), ^{
if (state == SQRLUpdaterStateCheckingForUpdate)
delegate->OnCheckingForUpdate();
else if (state == SQRLUpdaterStateDownloadingUpdate)
delegate->OnUpdateAvailable();
});
}];
}
// static
@ -111,32 +116,32 @@ void AutoUpdater::CheckForUpdates() {
if (!delegate)
return;
[[[[g_updater.checkForUpdatesCommand
execute:nil]
[[[[g_updater.checkForUpdatesCommand execute:nil]
// Send a `nil` after everything...
concat:[RACSignal return:nil]]
// But only take the first value. If an update is sent, we'll get that.
// Otherwise, we'll get our inserted `nil` value.
take:1]
subscribeNext:^(SQRLDownloadedUpdate *downloadedUpdate) {
subscribeNext:^(SQRLDownloadedUpdate* downloadedUpdate) {
if (downloadedUpdate) {
g_update_available = true;
SQRLUpdate* update = downloadedUpdate.update;
// There is a new update that has been downloaded.
delegate->OnUpdateDownloaded(
base::SysNSStringToUTF8(update.releaseNotes),
base::SysNSStringToUTF8(update.releaseName),
base::Time::FromDoubleT(update.releaseDate.timeIntervalSince1970),
base::SysNSStringToUTF8(update.updateURL.absoluteString));
base::SysNSStringToUTF8(update.releaseNotes),
base::SysNSStringToUTF8(update.releaseName),
base::Time::FromDoubleT(update.releaseDate.timeIntervalSince1970),
base::SysNSStringToUTF8(update.updateURL.absoluteString));
} else {
g_update_available = false;
// When the completed event is sent with no update, then we know there
// is no update available.
delegate->OnUpdateNotAvailable();
}
} error:^(NSError *error) {
NSMutableString *failureString =
[NSMutableString stringWithString:error.localizedDescription];
}
error:^(NSError* error) {
NSMutableString* failureString =
[NSMutableString stringWithString:error.localizedDescription];
if (error.localizedFailureReason) {
[failureString appendString:@": "];
[failureString appendString:error.localizedFailureReason];