Apply clang-format to all C, C++ and ObjC files (issue #2171)

This commit is contained in:
Marshall Greenblatt
2017-05-17 11:29:28 +02:00
parent a566549e04
commit 31d9407ee2
1331 changed files with 33014 additions and 32258 deletions

View File

@@ -69,7 +69,7 @@ void ClientAppBrowser::OnContextInitialized() {
}
void ClientAppBrowser::OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) {
CefRefPtr<CefCommandLine> command_line) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnBeforeChildProcessLaunch(this, command_line);

View File

@@ -13,8 +13,7 @@
namespace client {
// Client app implementation for the browser process.
class ClientAppBrowser : public ClientApp,
public CefBrowserProcessHandler {
class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
public:
// Interface for browser delegates. All Delegates must be returned via
// CreateDelegates. Do not perform work in the Delegate
@@ -36,7 +35,7 @@ class ClientAppBrowser : public ClientApp,
CefRefPtr<CefListValue> extra_info) {}
};
typedef std::set<CefRefPtr<Delegate> > DelegateSet;
typedef std::set<CefRefPtr<Delegate>> DelegateSet;
ClientAppBrowser();

View File

@@ -61,15 +61,14 @@ class MainMessageLoop {
};
#define CURRENTLY_ON_MAIN_THREAD() \
client::MainMessageLoop::Get()->RunsTasksOnCurrentThread()
client::MainMessageLoop::Get()->RunsTasksOnCurrentThread()
#define REQUIRE_MAIN_THREAD() DCHECK(CURRENTLY_ON_MAIN_THREAD())
#define MAIN_POST_TASK(task) \
client::MainMessageLoop::Get()->PostTask(task)
#define MAIN_POST_TASK(task) client::MainMessageLoop::Get()->PostTask(task)
#define MAIN_POST_CLOSURE(closure) \
client::MainMessageLoop::Get()->PostClosure(closure)
client::MainMessageLoop::Get()->PostClosure(closure)
// Use this struct in conjuction with RefCountedThreadSafe to ensure that an
// object is deleted on the main thread. For example:
@@ -92,7 +91,7 @@ class MainMessageLoop {
// foo = NULL; // Deletion of |foo| will occur on the main thread.
//
struct DeleteOnMainThread {
template<typename T>
template <typename T>
static void Destruct(const T* x) {
if (CURRENTLY_ON_MAIN_THREAD()) {
delete x;

View File

@@ -24,11 +24,10 @@ const int64 kMaxTimerDelay = 1000 / 30; // 30fps
client::MainMessageLoopExternalPump* g_external_message_pump = NULL;
} // namespace
} // namespace
MainMessageLoopExternalPump::MainMessageLoopExternalPump()
: is_active_(false),
reentrancy_detected_(false) {
: is_active_(false), reentrancy_detected_(false) {
DCHECK(!g_external_message_pump);
g_external_message_pump = this;
}

View File

@@ -22,25 +22,27 @@
#if !defined(HANDLE_EINTR)
#if !DCHECK_IS_ON()
#define HANDLE_EINTR(x) ({ \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
} while (eintr_wrapper_result == -1 && errno == EINTR); \
eintr_wrapper_result; \
})
#define HANDLE_EINTR(x) \
({ \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
} while (eintr_wrapper_result == -1 && errno == EINTR); \
eintr_wrapper_result; \
})
#else
#define HANDLE_EINTR(x) ({ \
int eintr_wrapper_counter = 0; \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
} while (eintr_wrapper_result == -1 && errno == EINTR && \
eintr_wrapper_counter++ < 100); \
eintr_wrapper_result; \
})
#define HANDLE_EINTR(x) \
({ \
int eintr_wrapper_counter = 0; \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
} while (eintr_wrapper_result == -1 && errno == EINTR && \
eintr_wrapper_counter++ < 100); \
eintr_wrapper_result; \
})
#endif // !DCHECK_IS_ON()
#endif // !defined(HANDLE_EINTR)
@@ -114,8 +116,8 @@ int GetTimeIntervalMilliseconds(const CefTime& from) {
// Be careful here. CefTime has a precision of microseconds, but we want a
// value in milliseconds. If there are 5.5ms left, should the delay be 5 or
// 6? It should be 6 to avoid executing delayed work too early.
int delay = static_cast<int>(
ceil((from.GetDoubleT() - now.GetDoubleT()) * 1000.0));
int delay =
static_cast<int>(ceil((from.GetDoubleT() - now.GetDoubleT()) * 1000.0));
// If this value is negative, then we need to run delayed work soon.
return delay < 0 ? 0 : delay;
@@ -125,8 +127,7 @@ struct WorkSource : public GSource {
MainMessageLoopExternalPumpLinux* pump;
};
gboolean WorkSourcePrepare(GSource* source,
gint* timeout_ms) {
gboolean WorkSourcePrepare(GSource* source, gint* timeout_ms) {
*timeout_ms = static_cast<WorkSource*>(source)->pump->HandlePrepare();
// We always return FALSE, so that our timeout is honored. If we were
// to return TRUE, the timeout would be considered to be 0 and the poll
@@ -142,31 +143,26 @@ gboolean WorkSourceCheck(GSource* source) {
gboolean WorkSourceDispatch(GSource* source,
GSourceFunc unused_func,
gpointer unused_data) {
static_cast<WorkSource*>(source)->pump->HandleDispatch();
// Always return TRUE so our source stays registered.
return TRUE;
}
// I wish these could be const, but g_source_new wants non-const.
GSourceFuncs WorkSourceFuncs = {
WorkSourcePrepare,
WorkSourceCheck,
WorkSourceDispatch,
NULL
};
GSourceFuncs WorkSourceFuncs = {WorkSourcePrepare, WorkSourceCheck,
WorkSourceDispatch, NULL};
MainMessageLoopExternalPumpLinux::MainMessageLoopExternalPumpLinux()
: should_quit_(false),
context_(g_main_context_default()),
wakeup_gpollfd_(new GPollFD) {
: should_quit_(false),
context_(g_main_context_default()),
wakeup_gpollfd_(new GPollFD) {
// Create our wakeup pipe, which is used to flag when work was scheduled.
int fds[2];
int ret = pipe(fds);
DCHECK_EQ(ret, 0);
(void)ret; // Prevent warning in release mode.
wakeup_pipe_read_ = fds[0];
wakeup_pipe_read_ = fds[0];
wakeup_pipe_write_ = fds[1];
wakeup_gpollfd_->fd = wakeup_pipe_read_;
wakeup_gpollfd_->events = G_IO_IN;
@@ -231,7 +227,7 @@ void MainMessageLoopExternalPumpLinux::OnScheduleMessagePumpWork(
// variables as we would then need locks all over. This ensures that if we
// are sleeping in a poll that we will wake up.
if (HANDLE_EINTR(write(wakeup_pipe_write_, &delay_ms, sizeof(int64))) !=
sizeof(int64)) {
sizeof(int64)) {
NOTREACHED() << "Could not write to the UI message loop wakeup pipe!";
}
}
@@ -293,11 +289,10 @@ bool MainMessageLoopExternalPumpLinux::IsTimerPending() {
return GetTimeIntervalMilliseconds(delayed_work_time_) > 0;
}
} // namespace
} // namespace
// static
scoped_ptr<MainMessageLoopExternalPump>
MainMessageLoopExternalPump::Create() {
scoped_ptr<MainMessageLoopExternalPump> MainMessageLoopExternalPump::Create() {
return scoped_ptr<MainMessageLoopExternalPump>(
new MainMessageLoopExternalPumpLinux());
}

View File

@@ -4,8 +4,8 @@
#include "tests/shared/browser/main_message_loop_external_pump.h"
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#include "include/cef_app.h"
@@ -82,8 +82,7 @@ class MainMessageLoopExternalPumpMac : public MainMessageLoopExternalPump {
namespace client {
MainMessageLoopExternalPumpMac::MainMessageLoopExternalPumpMac()
: owner_thread_([[NSThread currentThread] retain]),
timer_(nil) {
: owner_thread_([[NSThread currentThread] retain]), timer_(nil) {
event_handler_ = [[[EventHandler alloc] initWithPump:this] retain];
}
@@ -111,9 +110,9 @@ int MainMessageLoopExternalPumpMac::Run() {
// Do some work.
CefDoMessageLoopWork();
// Sleep to allow the CEF proc to do work.
[NSThread sleepForTimeInterval: 0.05];
[NSThread sleepForTimeInterval:0.05];
}
return 0;
@@ -141,16 +140,16 @@ void MainMessageLoopExternalPumpMac::SetTimer(int64 delay_ms) {
DCHECK(!timer_);
const double delay_s = static_cast<double>(delay_ms) / 1000.0;
timer_ = [[NSTimer timerWithTimeInterval: delay_s
target: event_handler_
selector: @selector(timerTimeout:)
userInfo: nil
repeats: NO] retain];
timer_ = [[NSTimer timerWithTimeInterval:delay_s
target:event_handler_
selector:@selector(timerTimeout:)
userInfo:nil
repeats:NO] retain];
// Add the timer to default and tracking runloop modes.
NSRunLoop* owner_runloop = [NSRunLoop currentRunLoop];
[owner_runloop addTimer: timer_ forMode: NSRunLoopCommonModes];
[owner_runloop addTimer: timer_ forMode: NSEventTrackingRunLoopMode];
[owner_runloop addTimer:timer_ forMode:NSRunLoopCommonModes];
[owner_runloop addTimer:timer_ forMode:NSEventTrackingRunLoopMode];
}
void MainMessageLoopExternalPumpMac::KillTimer() {
@@ -162,8 +161,7 @@ void MainMessageLoopExternalPumpMac::KillTimer() {
}
// static
scoped_ptr<MainMessageLoopExternalPump>
MainMessageLoopExternalPump::Create() {
scoped_ptr<MainMessageLoopExternalPump> MainMessageLoopExternalPump::Create() {
return scoped_ptr<MainMessageLoopExternalPump>(
new MainMessageLoopExternalPumpMac());
}

View File

@@ -36,7 +36,9 @@ class MainMessageLoopExternalPumpWin : public MainMessageLoopExternalPump {
bool IsTimerPending() OVERRIDE { return timer_pending_; }
private:
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam,
static LRESULT CALLBACK WndProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam);
// True if a timer event is currently pending.
@@ -47,8 +49,7 @@ class MainMessageLoopExternalPumpWin : public MainMessageLoopExternalPump {
};
MainMessageLoopExternalPumpWin::MainMessageLoopExternalPumpWin()
: timer_pending_(false),
main_thread_target_(NULL) {
: timer_pending_(false), main_thread_target_(NULL) {
HINSTANCE hInstance = GetModuleHandle(NULL);
const wchar_t* const kClassName = L"CEFMainTargetHWND";
@@ -60,8 +61,9 @@ MainMessageLoopExternalPumpWin::MainMessageLoopExternalPumpWin()
RegisterClassEx(&wcex);
// Create the message handling window.
main_thread_target_ = CreateWindowW(kClassName, NULL, WS_OVERLAPPEDWINDOW,
0, 0, 0, 0, HWND_MESSAGE , NULL, hInstance, NULL);
main_thread_target_ =
CreateWindowW(kClassName, NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0,
HWND_MESSAGE, NULL, hInstance, NULL);
DCHECK(main_thread_target_);
SetUserDataPtr(main_thread_target_, this);
}
@@ -91,11 +93,11 @@ int MainMessageLoopExternalPumpWin::Run() {
for (int i = 0; i < 10; ++i) {
// Do some work.
CefDoMessageLoopWork();
// Sleep to allow the CEF proc to do work.
Sleep(50);
}
return 0;
}
@@ -120,8 +122,10 @@ void MainMessageLoopExternalPumpWin::KillTimer() {
}
// static
LRESULT CALLBACK MainMessageLoopExternalPumpWin::WndProc(
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
LRESULT CALLBACK MainMessageLoopExternalPumpWin::WndProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam) {
if (msg == WM_TIMER || msg == kMsgHaveWork) {
MainMessageLoopExternalPumpWin* message_loop =
GetUserDataPtr<MainMessageLoopExternalPumpWin*>(hwnd);
@@ -137,11 +141,10 @@ LRESULT CALLBACK MainMessageLoopExternalPumpWin::WndProc(
return DefWindowProc(hwnd, msg, wparam, lparam);
}
} // namespace
} // namespace
// static
scoped_ptr<MainMessageLoopExternalPump>
MainMessageLoopExternalPump::Create() {
scoped_ptr<MainMessageLoopExternalPump> MainMessageLoopExternalPump::Create() {
return scoped_ptr<MainMessageLoopExternalPump>(
new MainMessageLoopExternalPumpWin());
}

View File

@@ -8,8 +8,7 @@
namespace client {
MainMessageLoopStd::MainMessageLoopStd() {
}
MainMessageLoopStd::MainMessageLoopStd() {}
int MainMessageLoopStd::Run() {
CefRunMessageLoop();

View File

@@ -15,7 +15,7 @@ bool GetResourceDir(std::string& dir) {
char buff[1024];
// Retrieve the executable path.
ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff)-1);
ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff) - 1);
if (len == -1)
return false;
@@ -27,10 +27,9 @@ bool GetResourceDir(std::string& dir) {
return false;
// Add "files" to the path.
strcpy(pos+1, "files"); // NOLINT(runtime/printf)
strcpy(pos + 1, "files");
dir = std::string(buff);
return true;
}
} // namespace client

View File

@@ -49,7 +49,7 @@ bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
std::string path;
if (!GetResourceDir(path))
if (!GetResourceDir(path))
return NULL;
path.append("/");

View File

@@ -13,10 +13,10 @@ namespace client {
namespace {
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) {
bool LoadBinaryResource(int binaryId, DWORD& dwSize, LPBYTE& pBytes) {
HINSTANCE hInst = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId),
MAKEINTRESOURCE(256));
HRSRC hRes =
FindResource(hInst, MAKEINTRESOURCE(binaryId), MAKEINTRESOURCE(256));
if (hRes) {
HGLOBAL hGlob = LoadResource(hInst, hRes);
if (hGlob) {
@@ -34,7 +34,7 @@ bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) {
class BinaryResourceProvider : public CefResourceManager::Provider {
public:
explicit BinaryResourceProvider(const std::string& url_path)
: url_path_(url_path) {
: url_path_(url_path) {
DCHECK(!url_path.empty());
}
@@ -55,8 +55,7 @@ class BinaryResourceProvider : public CefResourceManager::Provider {
GetBinaryResourceReader(relative_path.data());
if (stream.get()) {
handler = new CefStreamResourceHandler(
request->mime_type_resolver().Run(url),
stream);
request->mime_type_resolver().Run(url), stream);
}
}

View File

@@ -10,8 +10,8 @@ namespace client {
void SetUserDataPtr(HWND hWnd, void* ptr) {
SetLastError(ERROR_SUCCESS);
LONG_PTR result = ::SetWindowLongPtr(
hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(ptr));
LONG_PTR result =
::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(ptr));
CHECK(result != 0 || GetLastError() == ERROR_SUCCESS);
}
@@ -19,14 +19,14 @@ WNDPROC SetWndProcPtr(HWND hWnd, WNDPROC wndProc) {
WNDPROC old =
reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWLP_WNDPROC));
CHECK(old != NULL);
LONG_PTR result = ::SetWindowLongPtr(
hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(wndProc));
LONG_PTR result = ::SetWindowLongPtr(hWnd, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(wndProc));
CHECK(result != 0 || GetLastError() == ERROR_SUCCESS);
return old;
}
std::wstring GetResourceString(UINT id) {
#define MAX_LOADSTRING 100
#define MAX_LOADSTRING 100
TCHAR buff[MAX_LOADSTRING] = {0};
LoadString(::GetModuleHandle(NULL), id, buff, MAX_LOADSTRING);
return buff;
@@ -71,66 +71,66 @@ int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) {
modifiers |= EVENTFLAG_CAPS_LOCK_ON;
switch (wparam) {
case VK_RETURN:
if ((lparam >> 16) & KF_EXTENDED)
case VK_RETURN:
if ((lparam >> 16) & KF_EXTENDED)
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_INSERT:
case VK_DELETE:
case VK_HOME:
case VK_END:
case VK_PRIOR:
case VK_NEXT:
case VK_UP:
case VK_DOWN:
case VK_LEFT:
case VK_RIGHT:
if (!((lparam >> 16) & KF_EXTENDED))
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_NUMLOCK:
case VK_NUMPAD0:
case VK_NUMPAD1:
case VK_NUMPAD2:
case VK_NUMPAD3:
case VK_NUMPAD4:
case VK_NUMPAD5:
case VK_NUMPAD6:
case VK_NUMPAD7:
case VK_NUMPAD8:
case VK_NUMPAD9:
case VK_DIVIDE:
case VK_MULTIPLY:
case VK_SUBTRACT:
case VK_ADD:
case VK_DECIMAL:
case VK_CLEAR:
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_INSERT:
case VK_DELETE:
case VK_HOME:
case VK_END:
case VK_PRIOR:
case VK_NEXT:
case VK_UP:
case VK_DOWN:
case VK_LEFT:
case VK_RIGHT:
if (!((lparam >> 16) & KF_EXTENDED))
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_NUMLOCK:
case VK_NUMPAD0:
case VK_NUMPAD1:
case VK_NUMPAD2:
case VK_NUMPAD3:
case VK_NUMPAD4:
case VK_NUMPAD5:
case VK_NUMPAD6:
case VK_NUMPAD7:
case VK_NUMPAD8:
case VK_NUMPAD9:
case VK_DIVIDE:
case VK_MULTIPLY:
case VK_SUBTRACT:
case VK_ADD:
case VK_DECIMAL:
case VK_CLEAR:
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_SHIFT:
if (IsKeyDown(VK_LSHIFT))
break;
case VK_SHIFT:
if (IsKeyDown(VK_LSHIFT))
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RSHIFT))
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_CONTROL:
if (IsKeyDown(VK_LCONTROL))
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RCONTROL))
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_MENU:
if (IsKeyDown(VK_LMENU))
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RMENU))
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_LWIN:
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RSHIFT))
break;
case VK_RWIN:
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_CONTROL:
if (IsKeyDown(VK_LCONTROL))
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RCONTROL))
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_MENU:
if (IsKeyDown(VK_LMENU))
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RMENU))
modifiers |= EVENTFLAG_IS_RIGHT;
break;
case VK_LWIN:
modifiers |= EVENTFLAG_IS_LEFT;
break;
case VK_RWIN:
modifiers |= EVENTFLAG_IS_RIGHT;
break;
break;
}
return modifiers;
}

View File

@@ -19,9 +19,7 @@ const char kZygoteProcess[] = "zygote";
} // namespace
ClientApp::ClientApp() {
}
ClientApp::ClientApp() {}
// static
ClientApp::ProcessType ClientApp::GetProcessType(

View File

@@ -8,7 +8,6 @@
namespace client {
ClientAppOther::ClientAppOther() {
}
ClientAppOther::ClientAppOther() {}
} // namespace client

View File

@@ -30,7 +30,6 @@ int RunMain(int argc, char* argv[]) {
} // namespace client
// Process entry point.
int main(int argc, char* argv[]) {
return client::RunMain(argc, argv);

View File

@@ -109,8 +109,8 @@ bool ClientAppRenderer::OnProcessMessageReceived(
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end() && !handled; ++it) {
handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
message);
handled =
(*it)->OnProcessMessageReceived(this, browser, source_process, message);
}
return handled;

View File

@@ -13,8 +13,7 @@
namespace client {
// Client app implementation for the renderer process.
class ClientAppRenderer : public ClientApp,
public CefRenderProcessHandler {
class ClientAppRenderer : public ClientApp, public CefRenderProcessHandler {
public:
// Interface for renderer delegates. All Delegates must be returned via
// CreateDelegates. Do not perform work in the Delegate
@@ -81,7 +80,7 @@ class ClientAppRenderer : public ClientApp,
}
};
typedef std::set<CefRefPtr<Delegate> > DelegateSet;
typedef std::set<CefRefPtr<Delegate>> DelegateSet;
ClientAppRenderer();
@@ -120,10 +119,9 @@ class ClientAppRenderer : public ClientApp,
void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) OVERRIDE;
bool OnProcessMessageReceived(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE;
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE;
private:
// Set of supported Delegates.