Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Unified Diff: ppapi/thunk/enter.cc

Issue 238923007: PPAPI: Format ppapi/thunk using clang-format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Popen instead, force carriage returns in thunks Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/thunk/enter.cc
diff --git a/ppapi/thunk/enter.cc b/ppapi/thunk/enter.cc
index 03937c9b5338b353b469fc9d92366b9f2eb1247e..a321962f31b2b2f215a33f0e63234411243bd687 100644
--- a/ppapi/thunk/enter.cc
+++ b/ppapi/thunk/enter.cc
@@ -19,8 +19,9 @@ namespace ppapi {
namespace {
bool IsMainThread() {
- return
- PpapiGlobals::Get()->GetMainThreadMessageLoop()->BelongsToCurrentThread();
+ return PpapiGlobals::Get()
+ ->GetMainThreadMessageLoop()
+ ->BelongsToCurrentThread();
}
} // namespace
@@ -29,36 +30,31 @@ namespace thunk {
namespace subtle {
-EnterBase::EnterBase()
- : resource_(NULL),
- retval_(PP_OK) {
+EnterBase::EnterBase() : resource_(NULL), retval_(PP_OK) {
PpapiGlobals::Get()->MarkPluginIsActive();
}
EnterBase::EnterBase(PP_Resource resource)
- : resource_(GetResource(resource)),
- retval_(PP_OK) {
+ : resource_(GetResource(resource)), retval_(PP_OK) {
PpapiGlobals::Get()->MarkPluginIsActive();
}
EnterBase::EnterBase(PP_Instance instance, SingletonResourceID resource_id)
- : resource_(GetSingletonResource(instance, resource_id)),
- retval_(PP_OK) {
+ : resource_(GetSingletonResource(instance, resource_id)), retval_(PP_OK) {
PpapiGlobals::Get()->MarkPluginIsActive();
}
EnterBase::EnterBase(PP_Resource resource,
const PP_CompletionCallback& callback)
- : resource_(GetResource(resource)),
- retval_(PP_OK) {
+ : resource_(GetResource(resource)), retval_(PP_OK) {
callback_ = new TrackedCallback(resource_, callback);
PpapiGlobals::Get()->MarkPluginIsActive();
}
-EnterBase::EnterBase(PP_Instance instance, SingletonResourceID resource_id,
+EnterBase::EnterBase(PP_Instance instance,
+ SingletonResourceID resource_id,
const PP_CompletionCallback& callback)
- : resource_(GetSingletonResource(instance, resource_id)),
- retval_(PP_OK) {
+ : resource_(GetSingletonResource(instance, resource_id)), retval_(PP_OK) {
if (!resource_)
retval_ = PP_ERROR_BADARGUMENT;
callback_ = new TrackedCallback(resource_, callback);
@@ -138,11 +134,10 @@ void EnterBase::SetStateForCallbackError(bool report_error) {
if (report_error) {
std::string message(
"Blocking callbacks are not allowed on the main thread.");
- PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
- std::string(), message);
+ PpapiGlobals::Get()->BroadcastLogWithSource(
+ 0, PP_LOGLEVEL_ERROR, std::string(), message);
}
- } else if (!IsMainThread() &&
- callback_->has_null_target_loop() &&
+ } else if (!IsMainThread() && callback_->has_null_target_loop() &&
!callback_->is_blocking()) {
// On a non-main thread, there must be a valid target loop for non-
// blocking callbacks, or we will have no place to run them.
@@ -152,11 +147,12 @@ void EnterBase::SetStateForCallbackError(bool report_error) {
// the plugin won't expect any return code other than
// PP_OK_COMPLETIONPENDING. So we crash to make the problem more obvious.
if (callback_->is_required()) {
- std::string message("Attempted to use a required callback, but there "
- "is no attached message loop on which to run the "
- "callback.");
- PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
- std::string(), message);
+ std::string message(
+ "Attempted to use a required callback, but there "
+ "is no attached message loop on which to run the "
+ "callback.");
+ PpapiGlobals::Get()->BroadcastLogWithSource(
+ 0, PP_LOGLEVEL_ERROR, std::string(), message);
LOG(FATAL) << message;
}
@@ -166,16 +162,14 @@ void EnterBase::SetStateForCallbackError(bool report_error) {
if (report_error) {
std::string message(
"The calling thread must have a message loop attached.");
- PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
- std::string(), message);
+ PpapiGlobals::Get()->BroadcastLogWithSource(
+ 0, PP_LOGLEVEL_ERROR, std::string(), message);
}
}
}
}
-void EnterBase::ClearCallback() {
- callback_ = NULL;
-}
+void EnterBase::ClearCallback() { callback_ = NULL; }
void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
Resource* resource_base,
@@ -208,15 +202,13 @@ void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
std::string message;
if (resource_base) {
message = base::StringPrintf(
- "0x%X is not the correct type for this function.",
- pp_resource);
+ "0x%X is not the correct type for this function.", pp_resource);
} else {
- message = base::StringPrintf(
- "0x%X is not a valid resource ID.",
- pp_resource);
+ message =
+ base::StringPrintf("0x%X is not a valid resource ID.", pp_resource);
}
- PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
- std::string(), message);
+ PpapiGlobals::Get()->BroadcastLogWithSource(
+ 0, PP_LOGLEVEL_ERROR, std::string(), message);
}
}
@@ -247,19 +239,17 @@ void EnterBase::SetStateForFunctionError(PP_Instance pp_instance,
// for PP_Resources above.
if (report_error && pp_instance) {
std::string message;
- message = base::StringPrintf(
- "0x%X is not a valid instance ID.",
- pp_instance);
- PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
- std::string(), message);
+ message =
+ base::StringPrintf("0x%X is not a valid instance ID.", pp_instance);
+ PpapiGlobals::Get()->BroadcastLogWithSource(
+ 0, PP_LOGLEVEL_ERROR, std::string(), message);
}
}
} // namespace subtle
EnterInstance::EnterInstance(PP_Instance instance)
- : EnterBase(),
- functions_(PpapiGlobals::Get()->GetInstanceAPI(instance)) {
+ : EnterBase(), functions_(PpapiGlobals::Get()->GetInstanceAPI(instance)) {
SetStateForFunctionError(instance, functions_, true);
}
@@ -273,18 +263,15 @@ EnterInstance::EnterInstance(PP_Instance instance,
SetStateForFunctionError(instance, functions_, true);
}
-EnterInstance::~EnterInstance() {
-}
+EnterInstance::~EnterInstance() {}
EnterInstanceNoLock::EnterInstanceNoLock(PP_Instance instance)
- : EnterBase(),
- functions_(PpapiGlobals::Get()->GetInstanceAPI(instance)) {
+ : EnterBase(), functions_(PpapiGlobals::Get()->GetInstanceAPI(instance)) {
SetStateForFunctionError(instance, functions_, true);
}
-EnterInstanceNoLock::EnterInstanceNoLock(
- PP_Instance instance,
- const PP_CompletionCallback& callback)
+EnterInstanceNoLock::EnterInstanceNoLock(PP_Instance instance,
+ const PP_CompletionCallback& callback)
: EnterBase(0 /* resource */, callback),
// TODO(dmichael): This means that the callback_ we get is not associated
// even with the instance, but we should handle that for
@@ -293,8 +280,7 @@ EnterInstanceNoLock::EnterInstanceNoLock(
SetStateForFunctionError(instance, functions_, true);
}
-EnterInstanceNoLock::~EnterInstanceNoLock() {
-}
+EnterInstanceNoLock::~EnterInstanceNoLock() {}
EnterResourceCreation::EnterResourceCreation(PP_Instance instance)
: EnterBase(),
@@ -302,8 +288,7 @@ EnterResourceCreation::EnterResourceCreation(PP_Instance instance)
SetStateForFunctionError(instance, functions_, true);
}
-EnterResourceCreation::~EnterResourceCreation() {
-}
+EnterResourceCreation::~EnterResourceCreation() {}
EnterResourceCreationNoLock::EnterResourceCreationNoLock(PP_Instance instance)
: EnterBase(),
@@ -311,8 +296,7 @@ EnterResourceCreationNoLock::EnterResourceCreationNoLock(PP_Instance instance)
SetStateForFunctionError(instance, functions_, true);
}
-EnterResourceCreationNoLock::~EnterResourceCreationNoLock() {
-}
+EnterResourceCreationNoLock::~EnterResourceCreationNoLock() {}
} // namespace thunk
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698