diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 21:12:36 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 21:12:36 +0000 |
commit | ad63b5c19a0cc18eab88fa90ab7a244cdf5a8b99 (patch) | |
tree | b6197fe4b3fe1a18e7d1ae59ff81fad94a2ee7b7 /content/renderer | |
parent | 02f1e6a8ebae2d5aa0e669ecdd1781f83caf0e70 (diff) | |
download | chromium_src-ad63b5c19a0cc18eab88fa90ab7a244cdf5a8b99.zip chromium_src-ad63b5c19a0cc18eab88fa90ab7a244cdf5a8b99.tar.gz chromium_src-ad63b5c19a0cc18eab88fa90ab7a244cdf5a8b99.tar.bz2 |
PPAPI: Run clang_format.py on content/renderer/pepper
BUG=345417
Review URL: https://codereview.chromium.org/225903006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263356 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
114 files changed, 2031 insertions, 2361 deletions
diff --git a/content/renderer/pepper/audio_helper.cc b/content/renderer/pepper/audio_helper.cc index 018f780..6adfab4 100644 --- a/content/renderer/pepper/audio_helper.cc +++ b/content/renderer/pepper/audio_helper.cc @@ -15,11 +15,9 @@ namespace content { // AudioHelper ----------------------------------------------------------------- -AudioHelper::AudioHelper() : shared_memory_size_for_create_callback_(0) { -} +AudioHelper::AudioHelper() : shared_memory_size_for_create_callback_(0) {} -AudioHelper::~AudioHelper() { -} +AudioHelper::~AudioHelper() {} int32_t AudioHelper::GetSyncSocketImpl(int* sync_socket) { if (socket_for_create_callback_) { @@ -28,7 +26,7 @@ int32_t AudioHelper::GetSyncSocketImpl(int* sync_socket) { #elif defined(OS_WIN) *sync_socket = reinterpret_cast<int>(socket_for_create_callback_->handle()); #else - #error "Platform not supported." +#error "Platform not supported." #endif return PP_OK; } @@ -40,10 +38,10 @@ int32_t AudioHelper::GetSharedMemoryImpl(int* shm_handle, uint32_t* shm_size) { #if defined(OS_POSIX) *shm_handle = shared_memory_for_create_callback_->handle().fd; #elif defined(OS_WIN) - *shm_handle = reinterpret_cast<int>( - shared_memory_for_create_callback_->handle()); + *shm_handle = + reinterpret_cast<int>(shared_memory_for_create_callback_->handle()); #else - #error "Platform not supported." +#error "Platform not supported." #endif *shm_size = shared_memory_size_for_create_callback_; return PP_OK; @@ -51,10 +49,9 @@ int32_t AudioHelper::GetSharedMemoryImpl(int* shm_handle, uint32_t* shm_size) { return PP_ERROR_FAILED; } -void AudioHelper::StreamCreated( - base::SharedMemoryHandle shared_memory_handle, - size_t shared_memory_size, - base::SyncSocket::Handle socket_handle) { +void AudioHelper::StreamCreated(base::SharedMemoryHandle shared_memory_handle, + size_t shared_memory_size, + base::SyncSocket::Handle socket_handle) { if (TrackedCallback::IsPending(create_callback_)) { // Trusted side of proxy can specify a callback to recieve handles. In // this case we don't need to map any data or start the thread since it diff --git a/content/renderer/pepper/audio_helper.h b/content/renderer/pepper/audio_helper.h index a111325..94f94fc 100644 --- a/content/renderer/pepper/audio_helper.h +++ b/content/renderer/pepper/audio_helper.h @@ -26,8 +26,7 @@ class AudioHelper { size_t shared_memory_size_, base::SyncSocket::Handle socket); - void SetCreateCallback( - scoped_refptr<ppapi::TrackedCallback> create_callback); + void SetCreateCallback(scoped_refptr<ppapi::TrackedCallback> create_callback); protected: // TODO(viettrungluu): This is all very poorly thought out. Refactor. diff --git a/content/renderer/pepper/common.h b/content/renderer/pepper/common.h index 9b440bf..02df9ef 100644 --- a/content/renderer/pepper/common.h +++ b/content/renderer/pepper/common.h @@ -10,15 +10,10 @@ namespace content { -inline PP_Bool BoolToPPBool(bool value) { - return value ? PP_TRUE : PP_FALSE; -} +inline PP_Bool BoolToPPBool(bool value) { return value ? PP_TRUE : PP_FALSE; } -inline bool PPBoolToBool(PP_Bool value) { - return (PP_TRUE == value); -} +inline bool PPBoolToBool(PP_Bool value) { return (PP_TRUE == value); } } // namespace content #endif // CONTENT_RENDERER_PEPPER_COMMON_H_ - diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc index aea22ba..a999541 100644 --- a/content/renderer/pepper/content_decryptor_delegate.cc +++ b/content/renderer/pepper/content_decryptor_delegate.cc @@ -43,7 +43,8 @@ namespace { // reference-count of 0. If |data| is NULL, sets |*resource| to NULL. Returns // true upon success and false if any error happened. bool MakeBufferResource(PP_Instance instance, - const uint8* data, uint32_t size, + const uint8* data, + uint32_t size, scoped_refptr<PPB_Buffer_Impl>* resource) { TRACE_EVENT0("media", "ContentDecryptorDelegate - MakeBufferResource"); DCHECK(resource); @@ -368,9 +369,7 @@ bool ContentDecryptorDelegate::Decrypt( SetBufferToFreeInTrackingInfo(&block_info.tracking_info); - plugin_decryption_interface_->Decrypt(pp_instance_, - pp_resource, - &block_info); + plugin_decryption_interface_->Decrypt(pp_instance_, pp_resource, &block_info); return true; } @@ -431,9 +430,8 @@ bool ContentDecryptorDelegate::InitializeAudioDecoder( ScopedPPResource pp_resource(extra_data_resource.get()); audio_decoder_init_cb_.Set(pp_decoder_config.request_id, init_cb); - plugin_decryption_interface_->InitializeAudioDecoder(pp_instance_, - &pp_decoder_config, - pp_resource); + plugin_decryption_interface_->InitializeAudioDecoder( + pp_instance_, &pp_decoder_config, pp_resource); return true; } @@ -463,9 +461,8 @@ bool ContentDecryptorDelegate::InitializeVideoDecoder( video_decoder_init_cb_.Set(pp_decoder_config.request_id, init_cb); natural_size_ = decoder_config.natural_size(); - plugin_decryption_interface_->InitializeVideoDecoder(pp_instance_, - &pp_decoder_config, - pp_resource); + plugin_decryption_interface_->InitializeVideoDecoder( + pp_instance_, &pp_decoder_config, pp_resource); return true; } @@ -500,7 +497,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio( // This is enforced by the media pipeline. scoped_refptr<PPB_Buffer_Impl> encrypted_resource; if (!MakeMediaBufferResource( - Decryptor::kAudio, encrypted_buffer, &encrypted_resource)) { + Decryptor::kAudio, encrypted_buffer, &encrypted_resource)) { return false; } @@ -525,10 +522,8 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio( audio_decode_cb_.Set(request_id, audio_decode_cb); ScopedPPResource pp_resource(encrypted_resource.get()); - plugin_decryption_interface_->DecryptAndDecode(pp_instance_, - PP_DECRYPTORSTREAMTYPE_AUDIO, - pp_resource, - &block_info); + plugin_decryption_interface_->DecryptAndDecode( + pp_instance_, PP_DECRYPTORSTREAMTYPE_AUDIO, pp_resource, &block_info); return true; } @@ -540,7 +535,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeVideo( // This is enforced by the media pipeline. scoped_refptr<PPB_Buffer_Impl> encrypted_resource; if (!MakeMediaBufferResource( - Decryptor::kVideo, encrypted_buffer, &encrypted_resource)) { + Decryptor::kVideo, encrypted_buffer, &encrypted_resource)) { return false; } @@ -568,10 +563,8 @@ bool ContentDecryptorDelegate::DecryptAndDecodeVideo( // TODO(tomfinegan): Need to get stream type from media stack. ScopedPPResource pp_resource(encrypted_resource.get()); - plugin_decryption_interface_->DecryptAndDecode(pp_instance_, - PP_DECRYPTORSTREAMTYPE_VIDEO, - pp_resource, - &block_info); + plugin_decryption_interface_->DecryptAndDecode( + pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); return true; } @@ -640,9 +633,9 @@ void ContentDecryptorDelegate::OnSessionError(uint32 session_id, } void ContentDecryptorDelegate::DecoderInitializeDone( - PP_DecryptorStreamType decoder_type, - uint32_t request_id, - PP_Bool success) { + PP_DecryptorStreamType decoder_type, + uint32_t request_id, + PP_Bool success) { if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { // If the request ID is not valid or does not match what's saved, do // nothing. @@ -721,10 +714,10 @@ void ContentDecryptorDelegate::DeliverBlock( // TODO(tomfinegan): Find a way to take ownership of the shared memory // managed by the PPB_Buffer_Dev, and avoid the extra copy. scoped_refptr<media::DecoderBuffer> decrypted_buffer( - media::DecoderBuffer::CopyFrom( - static_cast<uint8*>(mapper.data()), block_info->data_size)); - decrypted_buffer->set_timestamp(base::TimeDelta::FromMicroseconds( - block_info->tracking_info.timestamp)); + media::DecoderBuffer::CopyFrom(static_cast<uint8*>(mapper.data()), + block_info->data_size)); + decrypted_buffer->set_timestamp( + base::TimeDelta::FromMicroseconds(block_info->tracking_info.timestamp)); decrypt_cb.Run(Decryptor::kSuccess, decrypted_buffer); } @@ -929,8 +922,8 @@ bool ContentDecryptorDelegate::MakeMediaBufferResource( << ((stream_type == Decryptor::kAudio) ? "audio" : "video") << " stream bumped to " << media_resource_size << " bytes to fit input."; - media_resource = PPB_Buffer_Impl::CreateResource(pp_instance_, - media_resource_size); + media_resource = + PPB_Buffer_Impl::CreateResource(pp_instance_, media_resource_size); if (!media_resource.get()) return false; } @@ -990,8 +983,8 @@ bool ContentDecryptorDelegate::DeserializeAudioFrames( return false; // Allocate space for the channel pointers given to AudioBuffer. - std::vector<const uint8*> channel_ptrs( - audio_channel_count_, static_cast<const uint8*>(NULL)); + std::vector<const uint8*> channel_ptrs(audio_channel_count_, + static_cast<const uint8*>(NULL)); do { int64 timestamp = 0; int64 frame_size = -1; diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc index 651aafe..87ade57 100644 --- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc +++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc @@ -41,8 +41,7 @@ namespace content { #if defined(ENABLE_WEBRTC) namespace { -bool CanUseMediaStreamAPI(const RendererPpapiHost* host, - PP_Instance instance) { +bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { blink::WebPluginContainer* container = host->GetContainerForInstance(instance); if (!container) @@ -59,11 +58,9 @@ bool CanUseMediaStreamAPI(const RendererPpapiHost* host, ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( RendererPpapiHostImpl* host) - : host_(host) { -} + : host_(host) {} -ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() { -} +ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() {} scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( ppapi::host::PpapiHost* host, @@ -87,7 +84,7 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( PP_Resource file_system; std::string internal_path; if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>( - message, &file_system, &internal_path)) { + message, &file_system, &internal_path)) { NOTREACHED(); return scoped_ptr<ResourceHost>(); } @@ -107,23 +104,27 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( case PpapiHostMsg_Graphics2D_Create::ID: { PP_Size size; PP_Bool is_always_opaque; - if (!UnpackMessage<PpapiHostMsg_Graphics2D_Create>(message, &size, - &is_always_opaque)) { + if (!UnpackMessage<PpapiHostMsg_Graphics2D_Create>( + message, &size, &is_always_opaque)) { NOTREACHED(); return scoped_ptr<ResourceHost>(); } scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( instance, ppapi::PPB_ImageData_Shared::PLATFORM)); return scoped_ptr<ResourceHost>( - PepperGraphics2DHost::Create(host_, instance, params.pp_resource(), - size, is_always_opaque, image_data)); + PepperGraphics2DHost::Create(host_, + instance, + params.pp_resource(), + size, + is_always_opaque, + image_data)); } case PpapiHostMsg_URLLoader_Create::ID: return scoped_ptr<ResourceHost>(new PepperURLLoaderHost( host_, false, instance, params.pp_resource())); case PpapiHostMsg_WebSocket_Create::ID: - return scoped_ptr<ResourceHost>(new PepperWebSocketHost( - host_, instance, params.pp_resource())); + return scoped_ptr<ResourceHost>( + new PepperWebSocketHost(host_, instance, params.pp_resource())); #if defined(ENABLE_WEBRTC) // These private MediaStream interfaces are exposed as if they were public // so they can be used by NaCl plugins. However, they are available only @@ -134,8 +135,8 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( host_, instance, params.pp_resource())); case PpapiHostMsg_VideoSource_Create::ID: if (CanUseMediaStreamAPI(host_, instance)) - return scoped_ptr<ResourceHost>(new PepperVideoSourceHost( - host_, instance, params.pp_resource())); + return scoped_ptr<ResourceHost>( + new PepperVideoSourceHost(host_, instance, params.pp_resource())); #endif // defined(ENABLE_WEBRTC) } @@ -143,15 +144,14 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { switch (message.type()) { case PpapiHostMsg_AudioInput_Create::ID: - return scoped_ptr<ResourceHost>(new PepperAudioInputHost( - host_, instance, params.pp_resource())); + return scoped_ptr<ResourceHost>( + new PepperAudioInputHost(host_, instance, params.pp_resource())); case PpapiHostMsg_FileChooser_Create::ID: - return scoped_ptr<ResourceHost>(new PepperFileChooserHost( - host_, instance, params.pp_resource())); + return scoped_ptr<ResourceHost>( + new PepperFileChooserHost(host_, instance, params.pp_resource())); case PpapiHostMsg_TrueTypeFont_Create::ID: { SerializedTrueTypeFontDesc desc; - if (!UnpackMessage<PpapiHostMsg_TrueTypeFont_Create>(message, - &desc)) { + if (!UnpackMessage<PpapiHostMsg_TrueTypeFont_Create>(message, &desc)) { NOTREACHED(); return scoped_ptr<ResourceHost>(); } @@ -164,8 +164,8 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( break; // Drop through and return null host. } case PpapiHostMsg_VideoCapture_Create::ID: { - PepperVideoCaptureHost* host = new PepperVideoCaptureHost( - host_, instance, params.pp_resource()); + PepperVideoCaptureHost* host = + new PepperVideoCaptureHost(host_, instance, params.pp_resource()); if (!host->Init()) { delete host; return scoped_ptr<ResourceHost>(); diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.h b/content/renderer/pepper/content_renderer_pepper_host_factory.h index cc790fa..8618b8b 100644 --- a/content/renderer/pepper/content_renderer_pepper_host_factory.h +++ b/content/renderer/pepper/content_renderer_pepper_host_factory.h @@ -20,8 +20,7 @@ class RenderViewImpl; class ContentRendererPepperHostFactory : public ppapi::host::HostFactory { public: - explicit ContentRendererPepperHostFactory( - RendererPpapiHostImpl* host); + explicit ContentRendererPepperHostFactory(RendererPpapiHostImpl* host); virtual ~ContentRendererPepperHostFactory(); virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( diff --git a/content/renderer/pepper/event_conversion.cc b/content/renderer/pepper/event_conversion.cc index 0243434..d44e38f 100644 --- a/content/renderer/pepper/event_conversion.cc +++ b/content/renderer/pepper/event_conversion.cc @@ -43,43 +43,43 @@ namespace { // not matching, we'll need to write conversion code to preserve the Pepper // values (since plugins will be depending on them). COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_SHIFTKEY) == - static_cast<int>(WebInputEvent::ShiftKey), + static_cast<int>(WebInputEvent::ShiftKey), ShiftKeyMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_CONTROLKEY) == - static_cast<int>(WebInputEvent::ControlKey), + static_cast<int>(WebInputEvent::ControlKey), ControlKeyMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_ALTKEY) == - static_cast<int>(WebInputEvent::AltKey), + static_cast<int>(WebInputEvent::AltKey), AltKeyMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_METAKEY) == - static_cast<int>(WebInputEvent::MetaKey), + static_cast<int>(WebInputEvent::MetaKey), MetaKeyMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_ISKEYPAD) == - static_cast<int>(WebInputEvent::IsKeyPad), + static_cast<int>(WebInputEvent::IsKeyPad), KeyPadMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT) == - static_cast<int>(WebInputEvent::IsAutoRepeat), + static_cast<int>(WebInputEvent::IsAutoRepeat), AutoRepeatMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN) == - static_cast<int>(WebInputEvent::LeftButtonDown), + static_cast<int>(WebInputEvent::LeftButtonDown), LeftButtonMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN) == - static_cast<int>(WebInputEvent::MiddleButtonDown), + static_cast<int>(WebInputEvent::MiddleButtonDown), MiddleButtonMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN) == - static_cast<int>(WebInputEvent::RightButtonDown), + static_cast<int>(WebInputEvent::RightButtonDown), RightButtonMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY) == - static_cast<int>(WebInputEvent::CapsLockOn), + static_cast<int>(WebInputEvent::CapsLockOn), CapsLockMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_NUMLOCKKEY) == - static_cast<int>(WebInputEvent::NumLockOn), + static_cast<int>(WebInputEvent::NumLockOn), NumLockMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_ISLEFT) == - static_cast<int>(WebInputEvent::IsLeft), + static_cast<int>(WebInputEvent::IsLeft), LeftMatches); COMPILE_ASSERT(static_cast<int>(PP_INPUTEVENT_MODIFIER_ISRIGHT) == - static_cast<int>(WebInputEvent::IsRight), + static_cast<int>(WebInputEvent::IsRight), RightMatches); PP_InputEvent_Type ConvertEventTypes(WebInputEvent::Type wetype) { @@ -172,20 +172,19 @@ void AppendCharEvent(const WebInputEvent& event, void AppendMouseEvent(const WebInputEvent& event, std::vector<InputEventData>* result_events) { COMPILE_ASSERT(static_cast<int>(WebMouseEvent::ButtonNone) == - static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_NONE), + static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_NONE), MouseNone); COMPILE_ASSERT(static_cast<int>(WebMouseEvent::ButtonLeft) == - static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_LEFT), + static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_LEFT), MouseLeft); COMPILE_ASSERT(static_cast<int>(WebMouseEvent::ButtonRight) == - static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_RIGHT), + static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_RIGHT), MouseRight); COMPILE_ASSERT(static_cast<int>(WebMouseEvent::ButtonMiddle) == - static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_MIDDLE), + static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_MIDDLE), MouseMiddle); - const WebMouseEvent& mouse_event = - static_cast<const WebMouseEvent&>(event); + const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); InputEventData result = GetEventWithCommonFieldsAndType(event); result.event_modifiers = mouse_event.modifiers; if (mouse_event.type == WebInputEvent::MouseDown || @@ -216,7 +215,8 @@ void AppendMouseWheelEvent(const WebInputEvent& event, result_events->push_back(result); } -void SetPPTouchPoints(const WebTouchPoint* touches, uint32_t touches_length, +void SetPPTouchPoints(const WebTouchPoint* touches, + uint32_t touches_length, std::vector<PP_TouchPoint>* result) { for (uint32_t i = 0; i < touches_length; i++) { const WebTouchPoint& touch_point = touches[i]; @@ -238,11 +238,13 @@ void AppendTouchEvent(const WebInputEvent& event, reinterpret_cast<const WebTouchEvent&>(event); InputEventData result = GetEventWithCommonFieldsAndType(event); - SetPPTouchPoints(touch_event.touches, touch_event.touchesLength, - &result.touches); - SetPPTouchPoints(touch_event.changedTouches, touch_event.changedTouchesLength, + SetPPTouchPoints( + touch_event.touches, touch_event.touchesLength, &result.touches); + SetPPTouchPoints(touch_event.changedTouches, + touch_event.changedTouchesLength, &result.changed_touches); - SetPPTouchPoints(touch_event.targetTouches, touch_event.targetTouchesLength, + SetPPTouchPoints(touch_event.targetTouches, + touch_event.targetTouchesLength, &result.target_touches); result_events->push_back(result); @@ -260,8 +262,9 @@ void SetWebTouchPoints(const std::vector<PP_TouchPoint>& pp_touches, WebTouchPoint* web_touches, uint32_t* web_touches_length) { - for (uint32_t i = 0; i < pp_touches.size() && - i < WebTouchEvent::touchesLengthCap; i++) { + for (uint32_t i = 0; + i < pp_touches.size() && i < WebTouchEvent::touchesLengthCap; + i++) { WebTouchPoint pt; const PP_TouchPoint& pp_pt = pp_touches[i]; pt.id = pp_pt.id; @@ -315,21 +318,27 @@ WebTouchEvent* BuildTouchEvent(const InputEventData& event) { web_event->timeStampSeconds = PPTimeTicksToEventTime(event.event_time_stamp); - SetWebTouchPoints(event.changed_touches, states_map, + SetWebTouchPoints(event.changed_touches, + states_map, web_event->changedTouches, &web_event->changedTouchesLength); - SetWebTouchPoints(event.touches, states_map, web_event->touches, - &web_event->touchesLength); + SetWebTouchPoints( + event.touches, states_map, web_event->touches, &web_event->touchesLength); - SetWebTouchPoints(event.target_touches, states_map, web_event->targetTouches, + SetWebTouchPoints(event.target_touches, + states_map, + web_event->targetTouches, &web_event->targetTouchesLength); if (web_event->type == WebInputEvent::TouchEnd || web_event->type == WebInputEvent::TouchCancel) { - SetWebTouchPoints(event.changed_touches, states_map, - web_event->touches, &web_event->touchesLength); - SetWebTouchPoints(event.changed_touches, states_map, + SetWebTouchPoints(event.changed_touches, + states_map, + web_event->touches, + &web_event->touchesLength); + SetWebTouchPoints(event.changed_touches, + states_map, web_event->targetTouches, &web_event->targetTouchesLength); } @@ -372,9 +381,7 @@ WebKeyboardEvent* BuildCharEvent(const InputEventData& event) { memset(key_event->text, 0, text_length_cap); memset(key_event->unmodifiedText, 0, text_length_cap); - for (size_t i = 0; - i < std::min(text_length_cap, text16.size()); - ++i) + for (size_t i = 0; i < std::min(text_length_cap, text16.size()); ++i) key_event->text[i] = text16[i]; return key_event; } @@ -406,8 +413,7 @@ WebMouseEvent* BuildMouseEvent(const InputEventData& event) { mouse_event->timeStampSeconds = PPTimeTicksToEventTime(event.event_time_stamp); mouse_event->modifiers = event.event_modifiers; - mouse_event->button = - static_cast<WebMouseEvent::Button>(event.mouse_button); + mouse_event->button = static_cast<WebMouseEvent::Button>(event.mouse_button); if (mouse_event->type == WebInputEvent::MouseMove) { if (mouse_event->modifiers & WebInputEvent::LeftButtonDown) mouse_event->button = WebMouseEvent::ButtonLeft; @@ -439,23 +445,23 @@ WebMouseWheelEvent* BuildMouseWheelEvent(const InputEventData& event) { } #if !defined(OS_WIN) -#define VK_RETURN 0x0D - -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E - -#define VK_APPS 0x5D - -#define VK_F1 0x70 +#define VK_RETURN 0x0D + +#define VK_PRIOR 0x21 +#define VK_NEXT 0x22 +#define VK_END 0x23 +#define VK_HOME 0x24 +#define VK_LEFT 0x25 +#define VK_UP 0x26 +#define VK_RIGHT 0x27 +#define VK_DOWN 0x28 +#define VK_SNAPSHOT 0x2C +#define VK_INSERT 0x2D +#define VK_DELETE 0x2E + +#define VK_APPS 0x5D + +#define VK_F1 0x70 #endif // Convert a character string to a Windows virtual key code. Adapted from @@ -515,7 +521,7 @@ void GetKeyCode(const std::string& char_text, *needs_shift_modifier = (vk_code & 0xFF) >= 'A' && (vk_code & 0xFF) <= 'Z'; if ((vk_code & 0xFF) >= 'a' && (vk_code & 0xFF) <= 'z') - vk_code -= 'a' - 'A'; + vk_code -= 'a' - 'A'; *generate_char = true; } } @@ -639,7 +645,7 @@ std::vector<linked_ptr<WebInputEvent> > CreateSimulatedWebInputEvents( case PP_INPUTEVENT_TYPE_RAWKEYDOWN: case PP_INPUTEVENT_TYPE_KEYDOWN: case PP_INPUTEVENT_TYPE_KEYUP: { - // Windows key down events should always be "raw" to avoid an ASSERT. +// Windows key down events should always be "raw" to avoid an ASSERT. #if defined(OS_WIN) WebKeyboardEvent* web_keyboard_event = static_cast<WebKeyboardEvent*>(original_event.get()); diff --git a/content/renderer/pepper/event_conversion.h b/content/renderer/pepper/event_conversion.h index 81aa6b3..59b8678 100644 --- a/content/renderer/pepper/event_conversion.h +++ b/content/renderer/pepper/event_conversion.h @@ -28,7 +28,7 @@ namespace content { // The generated events will be filled into the given vector. On failure, no // events will ge generated and the vector will be empty. void CreateInputEventData(const blink::WebInputEvent& event, - std::vector<ppapi::InputEventData >* pp_events); + std::vector<ppapi::InputEventData>* pp_events); // Creates a WebInputEvent from the given PP_InputEvent. If it fails, returns // NULL. The caller owns the created object on success. diff --git a/content/renderer/pepper/fake_pepper_plugin_instance.cc b/content/renderer/pepper/fake_pepper_plugin_instance.cc index 1a54058..53f20f6 100644 --- a/content/renderer/pepper/fake_pepper_plugin_instance.cc +++ b/content/renderer/pepper/fake_pepper_plugin_instance.cc @@ -11,25 +11,17 @@ namespace content { FakePepperPluginInstance::~FakePepperPluginInstance() {} -content::RenderView* FakePepperPluginInstance::GetRenderView() { - return NULL; -} +content::RenderView* FakePepperPluginInstance::GetRenderView() { return NULL; } blink::WebPluginContainer* FakePepperPluginInstance::GetContainer() { return NULL; } -v8::Isolate* FakePepperPluginInstance::GetIsolate() const { - return NULL; -} +v8::Isolate* FakePepperPluginInstance::GetIsolate() const { return NULL; } -ppapi::VarTracker* FakePepperPluginInstance::GetVarTracker() { - return NULL; -} +ppapi::VarTracker* FakePepperPluginInstance::GetVarTracker() { return NULL; } -const GURL& FakePepperPluginInstance::GetPluginURL() { - return gurl_; -} +const GURL& FakePepperPluginInstance::GetPluginURL() { return gurl_; } base::FilePath FakePepperPluginInstance::GetModulePath() { return base::FilePath(); @@ -51,9 +43,7 @@ PP_ExternalPluginResult FakePepperPluginInstance::SwitchToOutOfProcessProxy( void FakePepperPluginInstance::SetAlwaysOnTop(bool on_top) {} -bool FakePepperPluginInstance::IsFullPagePlugin() { - return false; -} +bool FakePepperPluginInstance::IsFullPagePlugin() { return false; } bool FakePepperPluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { diff --git a/content/renderer/pepper/fake_pepper_plugin_instance.h b/content/renderer/pepper/fake_pepper_plugin_instance.h index 30b5ca4..42e5f97 100644 --- a/content/renderer/pepper/fake_pepper_plugin_instance.h +++ b/content/renderer/pepper/fake_pepper_plugin_instance.h @@ -36,8 +36,8 @@ class FakePepperPluginInstance : public PepperPluginInstance { virtual int32_t Navigate(const ppapi::URLRequestInfoData& request, const char* target, bool from_user_action) OVERRIDE; - virtual int MakePendingFileRefRendererHost( - const base::FilePath& path) OVERRIDE; + virtual int MakePendingFileRefRendererHost(const base::FilePath& path) + OVERRIDE; virtual void SetEmbedProperty(PP_Var key, PP_Var value) OVERRIDE; virtual void SetSelectedText(const base::string16& selected_text) OVERRIDE; virtual void SetLinkUnderCursor(const std::string& url) OVERRIDE; diff --git a/content/renderer/pepper/host_array_buffer_var.cc b/content/renderer/pepper/host_array_buffer_var.cc index d8d4cec..ad8e97b 100644 --- a/content/renderer/pepper/host_array_buffer_var.cc +++ b/content/renderer/pepper/host_array_buffer_var.cc @@ -24,13 +24,10 @@ namespace content { HostArrayBufferVar::HostArrayBufferVar(uint32 size_in_bytes) : buffer_(WebArrayBuffer::create(size_in_bytes, 1 /* element_size */)), - valid_(true) { -} + valid_(true) {} HostArrayBufferVar::HostArrayBufferVar(const WebArrayBuffer& buffer) - : buffer_(buffer), - valid_(true) { -} + : buffer_(buffer), valid_(true) {} HostArrayBufferVar::HostArrayBufferVar(uint32 size_in_bytes, base::SharedMemoryHandle handle) @@ -43,8 +40,7 @@ HostArrayBufferVar::HostArrayBufferVar(uint32 size_in_bytes, } } -HostArrayBufferVar::~HostArrayBufferVar() { -} +HostArrayBufferVar::~HostArrayBufferVar() {} void* HostArrayBufferVar::Map() { if (!valid_) @@ -56,17 +52,16 @@ void HostArrayBufferVar::Unmap() { // We do not used shared memory on the host side. Nothing to do. } -uint32 HostArrayBufferVar::ByteLength() { - return buffer_.byteLength(); -} +uint32 HostArrayBufferVar::ByteLength() { return buffer_.byteLength(); } bool HostArrayBufferVar::CopyToNewShmem( PP_Instance instance, int* host_shm_handle_id, base::SharedMemoryHandle* plugin_shm_handle) { scoped_ptr<base::SharedMemory> shm( - RenderThread::Get()->HostAllocateSharedMemoryBuffer(ByteLength()). - release()); + RenderThread::Get() + ->HostAllocateSharedMemoryBuffer(ByteLength()) + .release()); if (!shm) return false; @@ -79,7 +74,7 @@ bool HostArrayBufferVar::CopyToNewShmem( HostGlobals* hg = HostGlobals::Get(); PluginModule* pm = hg->GetModule(hg->GetModuleForInstance(instance)); base::ProcessId p = pm->GetPeerProcessId(); - if (p == base::kNullProcessId) { + if (p == base::kNullProcessId) { // In-process, clone for ourselves. p = base::GetCurrentProcId(); } diff --git a/content/renderer/pepper/host_array_buffer_var.h b/content/renderer/pepper/host_array_buffer_var.h index 13bd806..12ae729 100644 --- a/content/renderer/pepper/host_array_buffer_var.h +++ b/content/renderer/pepper/host_array_buffer_var.h @@ -25,10 +25,10 @@ class HostArrayBufferVar : public ppapi::ArrayBufferVar { virtual void* Map() OVERRIDE; virtual void Unmap() OVERRIDE; virtual uint32 ByteLength() OVERRIDE; - virtual bool CopyToNewShmem( - PP_Instance instance, - int* host_shm_handle_id, - base::SharedMemoryHandle* plugin_shm_handle) OVERRIDE; + virtual bool CopyToNewShmem(PP_Instance instance, + int* host_shm_handle_id, + base::SharedMemoryHandle* plugin_shm_handle) + OVERRIDE; blink::WebArrayBuffer& webkit_buffer() { return buffer_; } diff --git a/content/renderer/pepper/host_dispatcher_wrapper.cc b/content/renderer/pepper/host_dispatcher_wrapper.cc index e55aec0..606d281 100644 --- a/content/renderer/pepper/host_dispatcher_wrapper.cc +++ b/content/renderer/pepper/host_dispatcher_wrapper.cc @@ -25,11 +25,9 @@ HostDispatcherWrapper::HostDispatcherWrapper( peer_pid_(peer_pid), plugin_child_id_(plugin_child_id), permissions_(perms), - is_external_(is_external) { -} + is_external_(is_external) {} -HostDispatcherWrapper::~HostDispatcherWrapper() { -} +HostDispatcherWrapper::~HostDispatcherWrapper() {} bool HostDispatcherWrapper::Init(const IPC::ChannelHandle& channel_handle, PP_GetInterface_Func local_get_interface, @@ -100,9 +98,7 @@ void HostDispatcherWrapper::RemoveInstance(PP_Instance instance) { RenderFrame* render_frame = host->GetRenderFrameForInstance(instance); if (render_frame) { render_frame->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( - plugin_child_id_, - instance, - is_external_)); + plugin_child_id_, instance, is_external_)); } } } diff --git a/content/renderer/pepper/host_globals.cc b/content/renderer/pepper/host_globals.cc index d4b9734..c8c44fa 100644 --- a/content/renderer/pepper/host_globals.cc +++ b/content/renderer/pepper/host_globals.cc @@ -41,12 +41,11 @@ namespace { typedef std::set<WebPluginContainer*> ContainerSet; // Adds all WebPluginContainers associated with the given module to the set. -void GetAllContainersForModule(PluginModule* module, - ContainerSet* containers) { - const PluginModule::PluginInstanceSet& instances = - module->GetAllInstances(); +void GetAllContainersForModule(PluginModule* module, ContainerSet* containers) { + const PluginModule::PluginInstanceSet& instances = module->GetAllInstances(); for (PluginModule::PluginInstanceSet::const_iterator i = instances.begin(); - i != instances.end(); ++i) { + i != instances.end(); + ++i) { WebPluginContainer* container = (*i)->container(); // If "Delete" is called on an instance, the instance sets its container to // NULL, but the instance may actually outlive its container. Callers of @@ -104,9 +103,7 @@ ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { return &resource_tracker_; } -ppapi::VarTracker* HostGlobals::GetVarTracker() { - return &host_var_tracker_; -} +ppapi::VarTracker* HostGlobals::GetVarTracker() { return &host_var_tracker_; } ppapi::CallbackTracker* HostGlobals::GetCallbackTrackerForInstance( PP_Instance instance) { @@ -153,8 +150,11 @@ void HostGlobals::LogWithSource(PP_Instance instance, PepperPluginInstanceImpl* instance_object = HostGlobals::Get()->GetInstance(instance); if (instance_object) { - instance_object->container()->element().document().frame()-> - addMessageToConsole(MakeLogMessage(level, source, value)); + instance_object->container() + ->element() + .document() + .frame() + ->addMessageToConsole(MakeLogMessage(level, source, value)); } else { BroadcastLogWithSource(0, level, source, value); } @@ -174,17 +174,18 @@ void HostGlobals::BroadcastLogWithSource(PP_Module pp_module, } else { // Unknown module, get containers for all modules. for (ModuleMap::const_iterator i = module_map_.begin(); - i != module_map_.end(); ++i) { + i != module_map_.end(); + ++i) { GetAllContainersForModule(i->second, &containers); } } WebConsoleMessage message = MakeLogMessage(level, source, value); - for (ContainerSet::iterator i = containers.begin(); - i != containers.end(); ++i) { - WebLocalFrame* frame = (*i)->element().document().frame(); - if (frame) - frame->addMessageToConsole(message); + for (ContainerSet::iterator i = containers.begin(); i != containers.end(); + ++i) { + WebLocalFrame* frame = (*i)->element().document().frame(); + if (frame) + frame->addMessageToConsole(message); } } @@ -192,15 +193,14 @@ base::TaskRunner* HostGlobals::GetFileTaskRunner() { return RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(); } -ppapi::MessageLoopShared* HostGlobals::GetCurrentMessageLoop() { - return NULL; -} +ppapi::MessageLoopShared* HostGlobals::GetCurrentMessageLoop() { return NULL; } PP_Module HostGlobals::AddModule(PluginModule* module) { #ifndef NDEBUG // Make sure we're not adding one more than once. for (ModuleMap::const_iterator i = module_map_.begin(); - i != module_map_.end(); ++i) + i != module_map_.end(); + ++i) DCHECK(i->second != module); #endif @@ -209,8 +209,7 @@ PP_Module HostGlobals::AddModule(PluginModule* module) { do { new_module = MakeTypedId(static_cast<PP_Module>(base::RandUint64()), ppapi::PP_ID_TYPE_MODULE); - } while (!new_module || - module_map_.find(new_module) != module_map_.end()); + } while (!new_module || module_map_.find(new_module) != module_map_.end()); module_map_[new_module] = module; return new_module; } @@ -276,8 +275,6 @@ PepperPluginInstanceImpl* HostGlobals::GetInstance(PP_Instance instance) { return found->second; } -bool HostGlobals::IsHostGlobals() const { - return true; -} +bool HostGlobals::IsHostGlobals() const { return true; } } // namespace content diff --git a/content/renderer/pepper/host_globals.h b/content/renderer/pepper/host_globals.h index 9d1b289..f91a65c 100644 --- a/content/renderer/pepper/host_globals.h +++ b/content/renderer/pepper/host_globals.h @@ -35,8 +35,8 @@ class HostGlobals : public ppapi::PpapiGlobals { virtual ppapi::VarTracker* GetVarTracker() OVERRIDE; virtual ppapi::CallbackTracker* GetCallbackTrackerForInstance( PP_Instance instance) OVERRIDE; - virtual ppapi::thunk::PPB_Instance_API* GetInstanceAPI( - PP_Instance instance) OVERRIDE; + virtual ppapi::thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) + OVERRIDE; virtual ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI( PP_Instance instance) OVERRIDE; virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; @@ -53,9 +53,7 @@ class HostGlobals : public ppapi::PpapiGlobals { virtual ppapi::MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; virtual base::TaskRunner* GetFileTaskRunner() OVERRIDE; - HostVarTracker* host_var_tracker() { - return &host_var_tracker_; - } + HostVarTracker* host_var_tracker() { return &host_var_tracker_; } // PP_Modules ---------------------------------------------------------------- @@ -111,4 +109,4 @@ class HostGlobals : public ppapi::PpapiGlobals { } // namespace content -#endif // CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ +#endif // CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ diff --git a/content/renderer/pepper/host_resource_var.cc b/content/renderer/pepper/host_resource_var.cc index 810a949..f67f4d6 100644 --- a/content/renderer/pepper/host_resource_var.cc +++ b/content/renderer/pepper/host_resource_var.cc @@ -20,9 +20,7 @@ HostResourceVar::HostResourceVar(int pending_renderer_host_id, pending_browser_host_id_(0), creation_message_(new IPC::Message(creation_message)) {} -PP_Resource HostResourceVar::GetPPResource() const { - return pp_resource_; -} +PP_Resource HostResourceVar::GetPPResource() const { return pp_resource_; } int HostResourceVar::GetPendingRendererHostId() const { return pending_renderer_host_id_; diff --git a/content/renderer/pepper/host_resource_var.h b/content/renderer/pepper/host_resource_var.h index cc6b057..1e8928a 100644 --- a/content/renderer/pepper/host_resource_var.h +++ b/content/renderer/pepper/host_resource_var.h @@ -38,9 +38,7 @@ class HostResourceVar : public ppapi::ResourceVar { virtual const IPC::Message* GetCreationMessage() const OVERRIDE; virtual bool IsPending() const OVERRIDE; - void set_pending_browser_host_id(int id) { - pending_browser_host_id_ = id; - } + void set_pending_browser_host_id(int id) { pending_browser_host_id_ = id; } protected: virtual ~HostResourceVar(); diff --git a/content/renderer/pepper/host_var_tracker.cc b/content/renderer/pepper/host_var_tracker.cc index 27f2977..700fbaf 100644 --- a/content/renderer/pepper/host_var_tracker.cc +++ b/content/renderer/pepper/host_var_tracker.cc @@ -17,12 +17,9 @@ using ppapi::NPObjectVar; namespace content { HostVarTracker::HostVarTracker() - : VarTracker(SINGLE_THREADED), - last_shared_memory_map_id_(0) { -} + : VarTracker(SINGLE_THREADED), last_shared_memory_map_id_(0) {} -HostVarTracker::~HostVarTracker() { -} +HostVarTracker::~HostVarTracker() {} ArrayBufferVar* HostVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { return new HostArrayBufferVar(size_in_bytes); @@ -37,28 +34,29 @@ ArrayBufferVar* HostVarTracker::CreateShmArrayBuffer( void HostVarTracker::AddNPObjectVar(NPObjectVar* object_var) { CheckThreadingPreconditions(); - InstanceMap::iterator found_instance = instance_map_.find( - object_var->pp_instance()); + InstanceMap::iterator found_instance = + instance_map_.find(object_var->pp_instance()); if (found_instance == instance_map_.end()) { // Lazily create the instance map. DCHECK(object_var->pp_instance() != 0); - found_instance = instance_map_.insert(std::make_pair( - object_var->pp_instance(), - linked_ptr<NPObjectToNPObjectVarMap>(new NPObjectToNPObjectVarMap))). - first; + found_instance = + instance_map_.insert(std::make_pair( + object_var->pp_instance(), + linked_ptr<NPObjectToNPObjectVarMap>( + new NPObjectToNPObjectVarMap))).first; } NPObjectToNPObjectVarMap* np_object_map = found_instance->second.get(); - DCHECK(np_object_map->find(object_var->np_object()) == - np_object_map->end()) << "NPObjectVar already in map"; + DCHECK(np_object_map->find(object_var->np_object()) == np_object_map->end()) + << "NPObjectVar already in map"; np_object_map->insert(std::make_pair(object_var->np_object(), object_var)); } void HostVarTracker::RemoveNPObjectVar(NPObjectVar* object_var) { CheckThreadingPreconditions(); - InstanceMap::iterator found_instance = instance_map_.find( - object_var->pp_instance()); + InstanceMap::iterator found_instance = + instance_map_.find(object_var->pp_instance()); if (found_instance == instance_map_.end()) { NOTREACHED() << "NPObjectVar has invalid instance."; return; diff --git a/content/renderer/pepper/host_var_tracker.h b/content/renderer/pepper/host_var_tracker.h index 5ab4df4..6abbf86 100644 --- a/content/renderer/pepper/host_var_tracker.h +++ b/content/renderer/pepper/host_var_tracker.h @@ -51,8 +51,7 @@ class HostVarTracker : public ppapi::VarTracker { // Returns the number of NPObjectVar's associated with the given instance. // Returns 0 if the instance isn't known. - CONTENT_EXPORT int GetLiveNPObjectVarsForInstance( - PP_Instance instance) const; + CONTENT_EXPORT int GetLiveNPObjectVarsForInstance(PP_Instance instance) const; // VarTracker public implementation. virtual PP_Var MakeResourcePPVarFromMessage( @@ -73,10 +72,11 @@ class HostVarTracker : public ppapi::VarTracker { private: // VarTracker private implementation. - virtual ppapi::ArrayBufferVar* CreateArrayBuffer( - uint32 size_in_bytes) OVERRIDE; + virtual ppapi::ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) + OVERRIDE; virtual ppapi::ArrayBufferVar* CreateShmArrayBuffer( - uint32 size_in_bytes, base::SharedMemoryHandle handle) OVERRIDE; + uint32 size_in_bytes, + base::SharedMemoryHandle handle) OVERRIDE; // Clear the reference count of the given object and remove it from // live_vars_. diff --git a/content/renderer/pepper/host_var_tracker_unittest.cc b/content/renderer/pepper/host_var_tracker_unittest.cc index 3fd334b1..07b759d 100644 --- a/content/renderer/pepper/host_var_tracker_unittest.cc +++ b/content/renderer/pepper/host_var_tracker_unittest.cc @@ -31,19 +31,8 @@ void TrackedClassDeallocate(NPObject* npobject) { } NPClass g_tracked_npclass = { - NP_CLASS_STRUCT_VERSION, - NULL, - &TrackedClassDeallocate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, -}; + NP_CLASS_STRUCT_VERSION, NULL, &TrackedClassDeallocate, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, }; // Returns a new tracked NPObject with a refcount of 1. You'll want to put this // in a NPObjectReleaser to free this ref when the test completes. @@ -57,9 +46,7 @@ NPObject* NewTrackedNPObject() { } struct ReleaseNPObject { - void operator()(NPObject* o) const { - blink::WebBindings::releaseObject(o); - } + void operator()(NPObject* o) const { blink::WebBindings::releaseObject(o); } }; // Handles automatically releasing a reference to the NPObject on destruction. @@ -70,12 +57,9 @@ typedef scoped_ptr<NPObject, ReleaseNPObject> NPObjectReleaser; class HostVarTrackerTest : public PpapiUnittest { public: - HostVarTrackerTest() { - } + HostVarTrackerTest() {} - HostVarTracker& tracker() { - return *HostGlobals::Get()->host_var_tracker(); - } + HostVarTracker& tracker() { return *HostGlobals::Get()->host_var_tracker(); } }; TEST_F(HostVarTrackerTest, DeleteObjectVarWithInstance) { @@ -118,8 +102,7 @@ TEST_F(HostVarTrackerTest, ReuseVar) { } // Remove both of the refs we made above. - ppapi::VarTracker* var_tracker = - ppapi::PpapiGlobals::Get()->GetVarTracker(); + ppapi::VarTracker* var_tracker = ppapi::PpapiGlobals::Get()->GetVarTracker(); var_tracker->ReleaseVar(static_cast<int32_t>(pp_object2.value.as_id)); var_tracker->ReleaseVar(static_cast<int32_t>(pp_object1.value.as_id)); diff --git a/content/renderer/pepper/message_channel.cc b/content/renderer/pepper/message_channel.cc index b824f62..81f49e9 100644 --- a/content/renderer/pepper/message_channel.cc +++ b/content/renderer/pepper/message_channel.cc @@ -44,18 +44,20 @@ namespace content { namespace { const char kPostMessage[] = "postMessage"; -const char kV8ToVarConversionError[] = "Failed to convert a PostMessage " +const char kV8ToVarConversionError[] = + "Failed to convert a PostMessage " "argument from a JavaScript value to a PP_Var. It may have cycles or be of " "an unsupported type."; -const char kVarToV8ConversionError[] = "Failed to convert a PostMessage " +const char kVarToV8ConversionError[] = + "Failed to convert a PostMessage " "argument from a PP_Var to a Javascript value. It may have cycles or be of " "an unsupported type."; // Helper function to get the MessageChannel that is associated with an // NPObject*. MessageChannel* ToMessageChannel(NPObject* object) { - return static_cast<MessageChannel::MessageChannelNPObject*>(object)-> - message_channel.get(); + return static_cast<MessageChannel::MessageChannelNPObject*>(object) + ->message_channel.get(); } NPObject* ToPassThroughObject(NPObject* object) { @@ -89,8 +91,9 @@ PP_Var CopyPPVar(const PP_Var& var) { ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(var); if (!buffer) return PP_MakeUndefined(); - PP_Var new_buffer_var = PpapiGlobals::Get()->GetVarTracker()-> - MakeArrayBufferPPVar(buffer->ByteLength()); + PP_Var new_buffer_var = + PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( + buffer->ByteLength()); DCHECK(new_buffer_var.type == PP_VARTYPE_ARRAY_BUFFER); if (new_buffer_var.type != PP_VARTYPE_ARRAY_BUFFER) return PP_MakeUndefined(); @@ -145,8 +148,10 @@ bool MessageChannelHasMethod(NPObject* np_obj, NPIdentifier name) { return false; } -bool MessageChannelInvoke(NPObject* np_obj, NPIdentifier name, - const NPVariant* args, uint32 arg_count, +bool MessageChannelInvoke(NPObject* np_obj, + NPIdentifier name, + const NPVariant* args, + uint32 arg_count, NPVariant* result) { if (!np_obj) return false; @@ -164,8 +169,8 @@ bool MessageChannelInvoke(NPObject* np_obj, NPIdentifier name, // Other method calls we will pass to the passthrough object, if we have one. NPObject* passthrough = ToPassThroughObject(np_obj); if (passthrough) { - return WebBindings::invoke(NULL, passthrough, name, args, arg_count, - result); + return WebBindings::invoke( + NULL, passthrough, name, args, arg_count, result); } return false; } @@ -180,8 +185,8 @@ bool MessageChannelInvokeDefault(NPObject* np_obj, // Invoke on the passthrough object, if we have one. NPObject* passthrough = ToPassThroughObject(np_obj); if (passthrough) { - return WebBindings::invokeDefault(NULL, passthrough, args, arg_count, - result); + return WebBindings::invokeDefault( + NULL, passthrough, args, arg_count, result); } return false; } @@ -203,7 +208,8 @@ bool MessageChannelHasProperty(NPObject* np_obj, NPIdentifier name) { return false; } -bool MessageChannelGetProperty(NPObject* np_obj, NPIdentifier name, +bool MessageChannelGetProperty(NPObject* np_obj, + NPIdentifier name, NPVariant* result) { if (!np_obj) return false; @@ -225,7 +231,8 @@ bool MessageChannelGetProperty(NPObject* np_obj, NPIdentifier name, return false; } -bool MessageChannelSetProperty(NPObject* np_obj, NPIdentifier name, +bool MessageChannelSetProperty(NPObject* np_obj, + NPIdentifier name, const NPVariant* variant) { if (!np_obj) return false; @@ -241,8 +248,9 @@ bool MessageChannelSetProperty(NPObject* np_obj, NPIdentifier name, return false; } -bool MessageChannelEnumerate(NPObject *np_obj, NPIdentifier **value, - uint32_t *count) { +bool MessageChannelEnumerate(NPObject* np_obj, + NPIdentifier** value, + uint32_t* count) { if (!np_obj) return false; @@ -258,7 +266,7 @@ bool MessageChannelEnumerate(NPObject *np_obj, NPIdentifier **value, return false; NPIdentifier* new_array = static_cast<NPIdentifier*>( std::malloc(sizeof(NPIdentifier) * (*count + 1))); - std::memcpy(new_array, *value, sizeof(NPIdentifier)*(*count)); + std::memcpy(new_array, *value, sizeof(NPIdentifier) * (*count)); new_array[*count] = WebBindings::getStringIdentifier(kPostMessage); std::free(*value); *value = new_array; @@ -275,38 +283,26 @@ bool MessageChannelEnumerate(NPObject *np_obj, NPIdentifier **value, } NPClass message_channel_class = { - NP_CLASS_STRUCT_VERSION, - &MessageChannelAllocate, - &MessageChannelDeallocate, - NULL, - &MessageChannelHasMethod, - &MessageChannelInvoke, - &MessageChannelInvokeDefault, - &MessageChannelHasProperty, - &MessageChannelGetProperty, - &MessageChannelSetProperty, - NULL, - &MessageChannelEnumerate, -}; + NP_CLASS_STRUCT_VERSION, &MessageChannelAllocate, + &MessageChannelDeallocate, NULL, + &MessageChannelHasMethod, &MessageChannelInvoke, + &MessageChannelInvokeDefault, &MessageChannelHasProperty, + &MessageChannelGetProperty, &MessageChannelSetProperty, + NULL, &MessageChannelEnumerate, }; } // namespace // MessageChannel -------------------------------------------------------------- struct MessageChannel::VarConversionResult { VarConversionResult(const ppapi::ScopedPPVar& r, bool s) - : result(r), - success(s), - conversion_completed(true) {} - VarConversionResult() - : success(false), - conversion_completed(false) {} + : result(r), success(s), conversion_completed(true) {} + VarConversionResult() : success(false), conversion_completed(false) {} ppapi::ScopedPPVar result; bool success; bool conversion_completed; }; -MessageChannel::MessageChannelNPObject::MessageChannelNPObject() { -} +MessageChannel::MessageChannelNPObject::MessageChannelNPObject() {} MessageChannel::MessageChannelNPObject::~MessageChannelNPObject() {} @@ -331,33 +327,34 @@ void MessageChannel::NPVariantToPPVar(const NPVariant* variant) { --converted_var_queue_.end(); switch (variant->type) { case NPVariantType_Void: - NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar(PP_MakeUndefined()), true); + NPVariantToPPVarComplete( + result_iterator, ppapi::ScopedPPVar(PP_MakeUndefined()), true); return; case NPVariantType_Null: - NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar(PP_MakeNull()), true); + NPVariantToPPVarComplete( + result_iterator, ppapi::ScopedPPVar(PP_MakeNull()), true); return; case NPVariantType_Bool: NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar( - PP_MakeBool(PP_FromBool(NPVARIANT_TO_BOOLEAN(*variant)))), - true); + ppapi::ScopedPPVar(PP_MakeBool(PP_FromBool( + NPVARIANT_TO_BOOLEAN(*variant)))), + true); return; case NPVariantType_Int32: - NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar( - PP_MakeInt32(NPVARIANT_TO_INT32(*variant))), + NPVariantToPPVarComplete( + result_iterator, + ppapi::ScopedPPVar(PP_MakeInt32(NPVARIANT_TO_INT32(*variant))), true); return; case NPVariantType_Double: - NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar( - PP_MakeDouble(NPVARIANT_TO_DOUBLE(*variant))), + NPVariantToPPVarComplete( + result_iterator, + ppapi::ScopedPPVar(PP_MakeDouble(NPVARIANT_TO_DOUBLE(*variant))), true); return; case NPVariantType_String: - NPVariantToPPVarComplete(result_iterator, + NPVariantToPPVarComplete( + result_iterator, ppapi::ScopedPPVar(ppapi::ScopedPPVar::PassRef(), StringVar::StringToPPVar( NPVARIANT_TO_STRING(*variant).UTF8Characters, @@ -368,15 +365,17 @@ void MessageChannel::NPVariantToPPVar(const NPVariant* variant) { // Calling WebBindings::toV8Value creates a wrapper around NPVariant so it // shouldn't result in a deep copy. v8::Handle<v8::Value> v8_value = WebBindings::toV8Value(variant); - V8VarConverter(instance_->pp_instance()).FromV8Value( - v8_value, v8::Isolate::GetCurrent()->GetCurrentContext(), - base::Bind(&MessageChannel::NPVariantToPPVarComplete, - weak_ptr_factory_.GetWeakPtr(), result_iterator)); + V8VarConverter(instance_->pp_instance()) + .FromV8Value(v8_value, + v8::Isolate::GetCurrent()->GetCurrentContext(), + base::Bind(&MessageChannel::NPVariantToPPVarComplete, + weak_ptr_factory_.GetWeakPtr(), + result_iterator)); return; } } - NPVariantToPPVarComplete(result_iterator, - ppapi::ScopedPPVar(PP_MakeUndefined()), false); + NPVariantToPPVarComplete( + result_iterator, ppapi::ScopedPPVar(PP_MakeUndefined()), false); } void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { @@ -398,10 +397,12 @@ void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { v8::Context::Scope context_scope(context); v8::Handle<v8::Value> v8_val; - if (!V8VarConverter(instance_->pp_instance()).ToV8Value( - message_data, context, &v8_val)) { + if (!V8VarConverter(instance_->pp_instance()) + .ToV8Value(message_data, context, &v8_val)) { PpapiGlobals::Get()->LogWithSource(instance_->pp_instance(), - PP_LOGLEVEL_ERROR, std::string(), kVarToV8ConversionError); + PP_LOGLEVEL_ERROR, + std::string(), + kVarToV8ConversionError); return; } @@ -458,7 +459,9 @@ void MessageChannel::NPVariantToPPVarComplete( PostMessageToNative(it->result.get()); } else { PpapiGlobals::Get()->LogWithSource(instance()->pp_instance(), - PP_LOGLEVEL_ERROR, std::string(), kV8ToVarConversionError); + PP_LOGLEVEL_ERROR, + std::string(), + kV8ToVarConversionError); } converted_var_queue_.erase(it++); @@ -497,13 +500,13 @@ void MessageChannel::PostMessageToJavaScriptImpl( WebDOMEvent event = container->element().document().createEvent("MessageEvent"); WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); - msg_event.initMessageEvent("message", // type - false, // canBubble - false, // cancelable + msg_event.initMessageEvent("message", // type + false, // canBubble + false, // cancelable message_data, // data - "", // origin [*] - NULL, // source [*] - ""); // lastEventId + "", // origin [*] + NULL, // source [*] + ""); // lastEventId // [*] Note that the |origin| is only specified for cross-document and server- // sent messages, while |source| is only specified for cross-document // messages: @@ -561,7 +564,7 @@ void MessageChannel::SetPassthroughObject(NPObject* passthrough) { } bool MessageChannel::GetReadOnlyProperty(NPIdentifier key, - NPVariant *value) const { + NPVariant* value) const { std::map<NPIdentifier, ppapi::ScopedPPVar>::const_iterator it = internal_properties_.find(key); if (it != internal_properties_.end()) { diff --git a/content/renderer/pepper/message_channel.h b/content/renderer/pepper/message_channel.h index e0020e6..222d56c 100644 --- a/content/renderer/pepper/message_channel.h +++ b/content/renderer/pepper/message_channel.h @@ -68,16 +68,12 @@ class MessageChannel { // related to postMessage. Note that this can be NULL; it only gets set if // there is a scriptable 'InstanceObject' associated with this channel's // instance. - NPObject* passthrough_object() { - return passthrough_object_; - } + NPObject* passthrough_object() { return passthrough_object_; } void SetPassthroughObject(NPObject* passthrough); NPObject* np_object() { return np_object_; } - PepperPluginInstanceImpl* instance() { - return instance_; - } + PepperPluginInstanceImpl* instance() { return instance_; } // Messages sent to JavaScript are queued by default. After the DOM is // set up for the plugin, users of MessageChannel should call @@ -126,10 +122,10 @@ class MessageChannel { // PluginInstance::ResetAsProxied() is gone. std::deque<blink::WebSerializedScriptValue> early_message_queue_; enum EarlyMessageQueueState { - QUEUE_MESSAGES, // Queue JS messages. - SEND_DIRECTLY, // Post JS messages directly. - DRAIN_PENDING, // Drain queue, then transition to DIRECT. - DRAIN_CANCELLED // Preempt drain, go back to QUEUE. + QUEUE_MESSAGES, // Queue JS messages. + SEND_DIRECTLY, // Post JS messages directly. + DRAIN_PENDING, // Drain queue, then transition to DIRECT. + DRAIN_CANCELLED // Preempt drain, go back to QUEUE. }; EarlyMessageQueueState early_message_queue_state_; diff --git a/content/renderer/pepper/mock_renderer_ppapi_host.cc b/content/renderer/pepper/mock_renderer_ppapi_host.cc index 2354f0b..da95d8f 100644 --- a/content/renderer/pepper/mock_renderer_ppapi_host.cc +++ b/content/renderer/pepper/mock_renderer_ppapi_host.cc @@ -16,11 +16,9 @@ MockRendererPpapiHost::MockRendererPpapiHost(RenderView* render_view, render_view_(render_view), pp_instance_(instance), has_user_gesture_(false), - plugin_instance_(new FakePepperPluginInstance) { -} + plugin_instance_(new FakePepperPluginInstance) {} -MockRendererPpapiHost::~MockRendererPpapiHost() { -} +MockRendererPpapiHost::~MockRendererPpapiHost() {} ppapi::host::PpapiHost* MockRendererPpapiHost::GetPpapiHost() { return &ppapi_host_; @@ -79,9 +77,7 @@ IPC::PlatformFileForTransit MockRendererPpapiHost::ShareHandleWithRemote( return IPC::InvalidPlatformFileForTransit(); } -bool MockRendererPpapiHost::IsRunningInProcess() const { - return false; -} +bool MockRendererPpapiHost::IsRunningInProcess() const { return false; } void MockRendererPpapiHost::CreateBrowserResourceHosts( PP_Instance instance, diff --git a/content/renderer/pepper/mock_renderer_ppapi_host.h b/content/renderer/pepper/mock_renderer_ppapi_host.h index c9d282a..f1ebbbc 100644 --- a/content/renderer/pepper/mock_renderer_ppapi_host.h +++ b/content/renderer/pepper/mock_renderer_ppapi_host.h @@ -22,8 +22,7 @@ class MockRendererPpapiHost : public RendererPpapiHost { public: // This function takes the RenderView and instance that the mock resource // host will be associated with. - MockRendererPpapiHost(RenderView* render_view, - PP_Instance instance); + MockRendererPpapiHost(RenderView* render_view, PP_Instance instance); virtual ~MockRendererPpapiHost(); ppapi::proxy::ResourceMessageTestSink& sink() { return sink_; } @@ -35,20 +34,20 @@ class MockRendererPpapiHost : public RendererPpapiHost { // RendererPpapiHost. virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; - virtual PepperPluginInstance* GetPluginInstance( - PP_Instance instance) const OVERRIDE; - virtual RenderFrame* GetRenderFrameForInstance( - PP_Instance instance) const OVERRIDE; - virtual RenderView* GetRenderViewForInstance( - PP_Instance instance) const OVERRIDE; + virtual PepperPluginInstance* GetPluginInstance(PP_Instance instance) const + OVERRIDE; + virtual RenderFrame* GetRenderFrameForInstance(PP_Instance instance) const + OVERRIDE; + virtual RenderView* GetRenderViewForInstance(PP_Instance instance) const + OVERRIDE; virtual blink::WebPluginContainer* GetContainerForInstance( PP_Instance instance) const OVERRIDE; virtual base::ProcessId GetPluginPID() const OVERRIDE; virtual bool HasUserGesture(PP_Instance instance) const OVERRIDE; virtual int GetRoutingIDForWidget(PP_Instance instance) const OVERRIDE; - virtual gfx::Point PluginPointToRenderFrame( - PP_Instance instance, - const gfx::Point& pt) const OVERRIDE; + virtual gfx::Point PluginPointToRenderFrame(PP_Instance instance, + const gfx::Point& pt) const + OVERRIDE; virtual IPC::PlatformFileForTransit ShareHandleWithRemote( base::PlatformFile handle, bool should_close_source) OVERRIDE; @@ -56,8 +55,8 @@ class MockRendererPpapiHost : public RendererPpapiHost { virtual void CreateBrowserResourceHosts( PP_Instance instance, const std::vector<IPC::Message>& nested_msgs, - const base::Callback<void( - const std::vector<int>&)>& callback) const OVERRIDE; + const base::Callback<void(const std::vector<int>&)>& callback) const + OVERRIDE; virtual GURL GetDocumentURL(PP_Instance instance) const OVERRIDE; private: diff --git a/content/renderer/pepper/npapi_glue.cc b/content/renderer/pepper/npapi_glue.cc index 240e5e3..fc55001 100644 --- a/content/renderer/pepper/npapi_glue.cc +++ b/content/renderer/pepper/npapi_glue.cc @@ -65,7 +65,6 @@ PP_Var NPObjectToPPVarImpl(PepperPluginInstanceImpl* instance, return object_var->GetPPVar(); } - } // namespace // Utilities ------------------------------------------------------------------- @@ -211,8 +210,7 @@ PPResultAndExceptionToNPResult::PPResultAndExceptionToNPResult( np_result_(np_result), exception_(PP_MakeUndefined()), success_(false), - checked_exception_(false) { -} + checked_exception_(false) {} PPResultAndExceptionToNPResult::~PPResultAndExceptionToNPResult() { // The user should have called SetResult or CheckExceptionForNoResult @@ -228,7 +226,7 @@ PPResultAndExceptionToNPResult::~PPResultAndExceptionToNPResult() { // the JS engine. It will update the success flag and return it. bool PPResultAndExceptionToNPResult::SetResult(PP_Var result) { DCHECK(!checked_exception_); // Don't call more than once. - DCHECK(np_result_); // Should be expecting a result. + DCHECK(np_result_); // Should be expecting a result. checked_exception_ = true; @@ -256,7 +254,7 @@ bool PPResultAndExceptionToNPResult::SetResult(PP_Var result) { // The success flag will be returned. bool PPResultAndExceptionToNPResult::CheckExceptionForNoResult() { DCHECK(!checked_exception_); // Don't call more than once. - DCHECK(!np_result_); // Can't have a result when doing this. + DCHECK(!np_result_); // Can't have a result when doing this. checked_exception_ = true; @@ -306,8 +304,7 @@ PPVarArrayFromNPVariantArray::~PPVarArrayFromNPVariantArray() { PPVarFromNPObject::PPVarFromNPObject(PepperPluginInstanceImpl* instance, NPObject* object) - : var_(NPObjectToPPVar(instance, object)) { -} + : var_(NPObjectToPPVar(instance, object)) {} PPVarFromNPObject::~PPVarFromNPObject() { PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var_); @@ -340,9 +337,7 @@ TryCatch::TryCatch(PP_Var* exception) WebBindings::pushExceptionHandler(&TryCatch::Catch, this); } -TryCatch::~TryCatch() { - WebBindings::popExceptionHandler(); -} +TryCatch::~TryCatch() { WebBindings::popExceptionHandler(); } void TryCatch::SetException(const char* message) { if (!has_exception()) { diff --git a/content/renderer/pepper/npapi_glue.h b/content/renderer/pepper/npapi_glue.h index c2d23c8..7bcbbff 100644 --- a/content/renderer/pepper/npapi_glue.h +++ b/content/renderer/pepper/npapi_glue.h @@ -64,8 +64,8 @@ PP_Var NPIdentifierToPPVar(NPIdentifier id); // Note: this could easily be changed to take a PP_Instance instead if that // makes certain calls in the future easier. Currently all callers have a // PluginInstance so that's what we use here. -CONTENT_EXPORT PP_Var NPObjectToPPVar(PepperPluginInstanceImpl* instance, - NPObject* object); +CONTENT_EXPORT PP_Var + NPObjectToPPVar(PepperPluginInstanceImpl* instance, NPObject* object); // This version creates a default v8::Context rather than using the one from // the container of |instance|. It is only for use in unit tests, where we don't @@ -112,9 +112,7 @@ class PPResultAndExceptionToNPResult { // Returns true if everything succeeded with no exception. This is valid only // after calling SetResult/CheckExceptionForNoResult. - bool success() const { - return success_; - } + bool success() const { return success_; } // Call this with the return value of the PPAPI function. It will convert // the result to the NPVariant output parameter and pass any exception on to @@ -139,7 +137,7 @@ class PPResultAndExceptionToNPResult { NPObject* object_var_; // Non-owning ref (see constructor). NPVariant* np_result_; // Output value, possibly NULL (see constructor). PP_Var exception_; // Exception set by the PPAPI call. We own a ref to it. - bool success_; // See the success() function above. + bool success_; // See the success() function above. bool checked_exception_; // SetResult/CheckExceptionForNoResult was called. DISALLOW_COPY_AND_ASSIGN(PPResultAndExceptionToNPResult); diff --git a/content/renderer/pepper/npobject_var.cc b/content/renderer/pepper/npobject_var.cc index c45d0d2..50ccf87 100644 --- a/content/renderer/pepper/npobject_var.cc +++ b/content/renderer/pepper/npobject_var.cc @@ -16,10 +16,8 @@ namespace ppapi { // NPObjectVar ----------------------------------------------------------------- -NPObjectVar::NPObjectVar(PP_Instance instance, - NPObject* np_object) - : pp_instance_(instance), - np_object_(np_object) { +NPObjectVar::NPObjectVar(PP_Instance instance, NPObject* np_object) + : pp_instance_(instance), np_object_(np_object) { WebBindings::retainObject(np_object_); content::HostGlobals::Get()->host_var_tracker()->AddNPObjectVar(this); } @@ -30,13 +28,9 @@ NPObjectVar::~NPObjectVar() { WebBindings::releaseObject(np_object_); } -NPObjectVar* NPObjectVar::AsNPObjectVar() { - return this; -} +NPObjectVar* NPObjectVar::AsNPObjectVar() { return this; } -PP_VarType NPObjectVar::GetType() const { - return PP_VARTYPE_OBJECT; -} +PP_VarType NPObjectVar::GetType() const { return PP_VARTYPE_OBJECT; } void NPObjectVar::InstanceDeleted() { DCHECK(pp_instance_); diff --git a/content/renderer/pepper/pepper_audio_input_host.cc b/content/renderer/pepper/pepper_audio_input_host.cc index 19aa2b1..7f63921 100644 --- a/content/renderer/pepper/pepper_audio_input_host.cc +++ b/content/renderer/pepper/pepper_audio_input_host.cc @@ -39,24 +39,19 @@ base::PlatformFile ConvertSharedMemoryHandle( } // namespace -PepperAudioInputHost::PepperAudioInputHost( - RendererPpapiHostImpl* host, - PP_Instance instance, - PP_Resource resource) +PepperAudioInputHost::PepperAudioInputHost(RendererPpapiHostImpl* host, + PP_Instance instance, + PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), audio_input_(NULL), - enumeration_helper_( - this, - PepperMediaDeviceManager::GetForRenderView( - host->GetRenderViewForInstance(pp_instance())), - PP_DEVICETYPE_DEV_AUDIOCAPTURE, - host->GetDocumentURL(instance)) { -} + enumeration_helper_(this, + PepperMediaDeviceManager::GetForRenderView( + host->GetRenderViewForInstance(pp_instance())), + PP_DEVICETYPE_DEV_AUDIOCAPTURE, + host->GetDocumentURL(instance)) {} -PepperAudioInputHost::~PepperAudioInputHost() { - Close(); -} +PepperAudioInputHost::~PepperAudioInputHost() { Close(); } int32_t PepperAudioInputHost::OnResourceMessageReceived( const IPC::Message& msg, @@ -66,11 +61,10 @@ int32_t PepperAudioInputHost::OnResourceMessageReceived( return result; IPC_BEGIN_MESSAGE_MAP(PepperAudioInputHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_Open, OnOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_StartOrStop, - OnStartOrStop); - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_AudioInput_Close, - OnClose); + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_Open, OnOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_AudioInput_StartOrStop, + OnStartOrStop); + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_AudioInput_Close, OnClose); IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -83,15 +77,16 @@ void PepperAudioInputHost::StreamCreated( } void PepperAudioInputHost::StreamCreationFailed() { - OnOpenComplete(PP_ERROR_FAILED, base::SharedMemory::NULLHandle(), 0, + OnOpenComplete(PP_ERROR_FAILED, + base::SharedMemory::NULLHandle(), + 0, base::SyncSocket::kInvalidHandle); } -int32_t PepperAudioInputHost::OnOpen( - ppapi::host::HostMessageContext* context, - const std::string& device_id, - PP_AudioSampleRate sample_rate, - uint32_t sample_frame_count) { +int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, + const std::string& device_id, + PP_AudioSampleRate sample_rate, + uint32_t sample_frame_count) { if (open_context_) return PP_ERROR_INPROGRESS; if (audio_input_) @@ -106,11 +101,13 @@ int32_t PepperAudioInputHost::OnOpen( RenderViewImpl* render_view = static_cast<RenderViewImpl*>( renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); - audio_input_ = PepperPlatformAudioInput::Create( - render_view->AsWeakPtr(), device_id, - document_url, - static_cast<int>(sample_rate), - static_cast<int>(sample_frame_count), this); + audio_input_ = + PepperPlatformAudioInput::Create(render_view->AsWeakPtr(), + device_id, + document_url, + static_cast<int>(sample_rate), + static_cast<int>(sample_frame_count), + this); if (audio_input_) { open_context_.reset(new ppapi::host::ReplyMessageContext( context->MakeReplyMessageContext())); @@ -214,4 +211,3 @@ void PepperAudioInputHost::Close() { } } // namespace content - diff --git a/content/renderer/pepper/pepper_audio_input_host.h b/content/renderer/pepper/pepper_audio_input_host.h index 70c4303..213fc37 100644 --- a/content/renderer/pepper/pepper_audio_input_host.h +++ b/content/renderer/pepper/pepper_audio_input_host.h @@ -44,8 +44,7 @@ class PepperAudioInputHost : public ppapi::host::ResourceHost { const std::string& device_id, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count); - int32_t OnStartOrStop(ppapi::host::HostMessageContext* context, - bool capture); + int32_t OnStartOrStop(ppapi::host::HostMessageContext* context, bool capture); int32_t OnClose(ppapi::host::HostMessageContext* context); void OnOpenComplete(int32_t result, diff --git a/content/renderer/pepper/pepper_broker.cc b/content/renderer/pepper/pepper_broker.cc index 4486196..0d23de1 100644 --- a/content/renderer/pepper/pepper_broker.cc +++ b/content/renderer/pepper/pepper_broker.cc @@ -40,18 +40,16 @@ base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) { // dup()ing and close()ing. out_handle = ::dup(handle); #else - #error Not implemented. +#error Not implemented. #endif return out_handle; } } // namespace -PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() { -} +PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() {} -PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() { -} +PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() {} bool PepperBrokerDispatcherWrapper::Init( base::ProcessId broker_pid, @@ -66,8 +64,7 @@ bool PepperBrokerDispatcherWrapper::Init( #endif dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); - dispatcher_.reset( - new ppapi::proxy::BrokerHostDispatcher()); + dispatcher_.reset(new ppapi::proxy::BrokerHostDispatcher()); if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), broker_pid, @@ -92,8 +89,8 @@ int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker( return PP_ERROR_FAILED; int32_t result; - if (!dispatcher_->Send( - new PpapiMsg_ConnectToPlugin(instance, foreign_socket_handle, &result))) { + if (!dispatcher_->Send(new PpapiMsg_ConnectToPlugin( + instance, foreign_socket_handle, &result))) { // The plugin did not receive the handle, so it must be closed. // The easiest way to clean it up is to just put it in an object // and then close it. This failure case is not performance critical. @@ -209,16 +206,15 @@ void PepperBroker::OnBrokerPermissionResult(PPB_Broker_Impl* client, entry->second.is_authorized = true; } -PepperBroker::PendingConnection::PendingConnection() : is_authorized(false) { -} +PepperBroker::PendingConnection::PendingConnection() : is_authorized(false) {} -PepperBroker::PendingConnection::~PendingConnection() { -} +PepperBroker::PendingConnection::~PendingConnection() {} void PepperBroker::ReportFailureToClients(int error_code) { DCHECK_NE(PP_OK, error_code); for (ClientMap::iterator i = pending_connects_.begin(); - i != pending_connects_.end(); ++i) { + i != pending_connects_.end(); + ++i) { base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client; if (weak_ptr.get()) { weak_ptr->BrokerConnected( diff --git a/content/renderer/pepper/pepper_broker.h b/content/renderer/pepper/pepper_broker.h index a363780..0703597 100644 --- a/content/renderer/pepper/pepper_broker.h +++ b/content/renderer/pepper/pepper_broker.h @@ -43,7 +43,7 @@ class CONTENT_EXPORT PepperBrokerDispatcherWrapper { scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; }; -class PepperBroker : public base::RefCountedThreadSafe<PepperBroker>{ +class PepperBroker : public base::RefCountedThreadSafe<PepperBroker> { public: explicit PepperBroker(PluginModule* plugin_module); @@ -62,8 +62,7 @@ class PepperBroker : public base::RefCountedThreadSafe<PepperBroker>{ // Called when we know whether permission to access the PPAPI broker was // granted. - void OnBrokerPermissionResult(PPB_Broker_Impl* client, - bool result); + void OnBrokerPermissionResult(PPB_Broker_Impl* client, bool result); private: friend class base::RefCountedThreadSafe<PepperBroker>; diff --git a/content/renderer/pepper/pepper_browser_connection.cc b/content/renderer/pepper/pepper_browser_connection.cc index 91b25ec..3394c56 100644 --- a/content/renderer/pepper/pepper_browser_connection.cc +++ b/content/renderer/pepper/pepper_browser_connection.cc @@ -19,11 +19,9 @@ namespace content { PepperBrowserConnection::PepperBrowserConnection(RenderFrame* render_frame) : RenderFrameObserver(render_frame), RenderFrameObserverTracker<PepperBrowserConnection>(render_frame), - next_sequence_number_(1) { -} + next_sequence_number_(1) {} -PepperBrowserConnection::~PepperBrowserConnection() { -} +PepperBrowserConnection::~PepperBrowserConnection() {} bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { // Check if the message is an in-process reply. @@ -32,9 +30,9 @@ bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply, - OnMsgCreateResourceHostsFromHostReply) - IPC_MESSAGE_UNHANDLED(handled = false) + IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply, + OnMsgCreateResourceHostsFromHostReply) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } @@ -47,10 +45,8 @@ void PepperBrowserConnection::DidCreateInProcessInstance( Send(new ViewHostMsg_DidCreateInProcessInstance( instance, // Browser provides the render process id. - PepperRendererInstanceData(0, - render_frame_id, - document_url, - plugin_url))); + PepperRendererInstanceData( + 0, render_frame_id, document_url, plugin_url))); } void PepperBrowserConnection::DidDeleteInProcessInstance(PP_Instance instance) { @@ -66,11 +62,7 @@ void PepperBrowserConnection::SendBrowserCreate( pending_create_map_[sequence_number] = callback; ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); Send(new PpapiHostMsg_CreateResourceHostsFromHost( - routing_id(), - child_process_id, - params, - instance, - nested_msgs)); + routing_id(), child_process_id, params, instance, nested_msgs)); } void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply( diff --git a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc index 28beb20..2e5496b 100644 --- a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc +++ b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc @@ -26,9 +26,8 @@ class PepperDeviceEnumerationHostHelper::ScopedRequest : public base::SupportsWeakPtr<ScopedRequest> { public: // |owner| must outlive this object. - ScopedRequest( - PepperDeviceEnumerationHostHelper* owner, - const Delegate::EnumerateDevicesCallback& callback) + ScopedRequest(PepperDeviceEnumerationHostHelper* owner, + const Delegate::EnumerateDevicesCallback& callback) : owner_(owner), callback_(callback), requested_(false), @@ -98,11 +97,9 @@ PepperDeviceEnumerationHostHelper::PepperDeviceEnumerationHostHelper( : resource_host_(resource_host), delegate_(delegate), device_type_(device_type), - document_url_(document_url) { -} + document_url_(document_url) {} -PepperDeviceEnumerationHostHelper::~PepperDeviceEnumerationHostHelper() { -} +PepperDeviceEnumerationHostHelper::~PepperDeviceEnumerationHostHelper() {} bool PepperDeviceEnumerationHostHelper::HandleResourceMessage( const IPC::Message& msg, @@ -119,14 +116,13 @@ int32_t PepperDeviceEnumerationHostHelper::InternalHandleResourceMessage( bool* handled) { *handled = true; IPC_BEGIN_MESSAGE_MAP(PepperDeviceEnumerationHostHelper, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_DeviceEnumeration_EnumerateDevices, OnEnumerateDevices) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_DeviceEnumeration_MonitorDeviceChange, - OnMonitorDeviceChange) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_DeviceEnumeration_StopMonitoringDeviceChange, - OnStopMonitoringDeviceChange) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_DeviceEnumeration_EnumerateDevices, OnEnumerateDevices) + PPAPI_DISPATCH_HOST_RESOURCE_CALL( + PpapiHostMsg_DeviceEnumeration_MonitorDeviceChange, OnMonitorDeviceChange) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_DeviceEnumeration_StopMonitoringDeviceChange, + OnStopMonitoringDeviceChange) IPC_END_MESSAGE_MAP() *handled = false; @@ -156,7 +152,8 @@ int32_t PepperDeviceEnumerationHostHelper::OnMonitorDeviceChange( monitor_.reset(new ScopedRequest( this, base::Bind(&PepperDeviceEnumerationHostHelper::OnNotifyDeviceChange, - base::Unretained(this), callback_id))); + base::Unretained(this), + callback_id))); return monitor_->requested() ? PP_OK : PP_ERROR_FAILED; } @@ -187,9 +184,8 @@ void PepperDeviceEnumerationHostHelper::OnNotifyDeviceChange( const std::vector<ppapi::DeviceRefData>& devices) { resource_host_->host()->SendUnsolicitedReply( resource_host_->pp_resource(), - PpapiPluginMsg_DeviceEnumeration_NotifyDeviceChange( - callback_id, - devices)); + PpapiPluginMsg_DeviceEnumeration_NotifyDeviceChange(callback_id, + devices)); } } // namespace content diff --git a/content/renderer/pepper/pepper_device_enumeration_host_helper.h b/content/renderer/pepper/pepper_device_enumeration_host_helper.h index 4142dec7..4fb38d9f 100644 --- a/content/renderer/pepper/pepper_device_enumeration_host_helper.h +++ b/content/renderer/pepper/pepper_device_enumeration_host_helper.h @@ -42,8 +42,8 @@ class CONTENT_EXPORT PepperDeviceEnumerationHostHelper { virtual ~Delegate() {} typedef base::Callback< - void (int /* request_id */, - const std::vector<ppapi::DeviceRefData>& /* devices */)> + void(int /* request_id */, + const std::vector<ppapi::DeviceRefData>& /* devices */)> EnumerateDevicesCallback; // Enumerates devices of the specified type. The request ID passed into the @@ -87,10 +87,9 @@ class CONTENT_EXPORT PepperDeviceEnumerationHostHelper { void OnEnumerateDevicesComplete( int request_id, const std::vector<ppapi::DeviceRefData>& devices); - void OnNotifyDeviceChange( - uint32_t callback_id, - int request_id, - const std::vector<ppapi::DeviceRefData>& devices); + void OnNotifyDeviceChange(uint32_t callback_id, + int request_id, + const std::vector<ppapi::DeviceRefData>& devices); // Non-owning pointers. ppapi::host::ResourceHost* resource_host_; diff --git a/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc b/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc index 298e953..a9b2579 100644 --- a/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc +++ b/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc @@ -26,17 +26,14 @@ namespace { class TestDelegate : public PepperDeviceEnumerationHostHelper::Delegate { public: - TestDelegate() : last_used_id_(0) { - } + TestDelegate() : last_used_id_(0) {} - virtual ~TestDelegate() { - CHECK(callbacks_.empty()); - } + virtual ~TestDelegate() { CHECK(callbacks_.empty()); } - virtual int EnumerateDevices( - PP_DeviceType_Dev /* type */, - const GURL& /* document_url */, - const EnumerateDevicesCallback& callback) OVERRIDE { + virtual int EnumerateDevices(PP_DeviceType_Dev /* type */, + const GURL& /* document_url */, + const EnumerateDevicesCallback& callback) + OVERRIDE { last_used_id_++; callbacks_[last_used_id_] = callback; return last_used_id_; @@ -78,10 +75,10 @@ class PepperDeviceEnumerationHostHelperTest : public testing::Test { PepperDeviceEnumerationHostHelperTest() : ppapi_host_(&sink_, ppapi::PpapiPermissions()), resource_host_(&ppapi_host_, 12345, 67890), - device_enumeration_(&resource_host_, &delegate_, + device_enumeration_(&resource_host_, + &delegate_, PP_DEVICETYPE_DEV_AUDIOCAPTURE, - GURL("http://example.com")) { - } + GURL("http://example.com")) {} virtual ~PepperDeviceEnumerationHostHelperTest() {} @@ -91,8 +88,8 @@ class PepperDeviceEnumerationHostHelperTest : public testing::Test { resource_host_.pp_resource(), 123); ppapi::host::HostMessageContext context(call_params); int32_t result = PP_ERROR_FAILED; - ASSERT_TRUE(device_enumeration_.HandleResourceMessage( - msg, &context, &result)); + ASSERT_TRUE( + device_enumeration_.HandleResourceMessage(msg, &context, &result)); EXPECT_EQ(PP_OK, result); } @@ -103,7 +100,8 @@ class PepperDeviceEnumerationHostHelperTest : public testing::Test { IPC::Message reply_msg; ASSERT_TRUE(sink_.GetFirstResourceReplyMatching( PpapiPluginMsg_DeviceEnumeration_NotifyDeviceChange::ID, - &reply_params, &reply_msg)); + &reply_params, + &reply_msg)); sink_.ClearMessages(); EXPECT_EQ(PP_OK, reply_params.result()); @@ -112,7 +110,7 @@ class PepperDeviceEnumerationHostHelperTest : public testing::Test { std::vector<ppapi::DeviceRefData> reply_data; ASSERT_TRUE(ppapi::UnpackMessage< PpapiPluginMsg_DeviceEnumeration_NotifyDeviceChange>( - reply_msg, &reply_callback_id, &reply_data)); + reply_msg, &reply_callback_id, &reply_data)); EXPECT_EQ(callback_id, reply_callback_id); EXPECT_EQ(expected, reply_data); } @@ -135,8 +133,8 @@ TEST_F(PepperDeviceEnumerationHostHelperTest, EnumerateDevices) { resource_host_.pp_resource(), 123); ppapi::host::HostMessageContext context(call_params); int32_t result = PP_ERROR_FAILED; - ASSERT_TRUE(device_enumeration_.HandleResourceMessage(msg, &context, - &result)); + ASSERT_TRUE( + device_enumeration_.HandleResourceMessage(msg, &context, &result)); EXPECT_EQ(PP_OK_COMPLETIONPENDING, result); EXPECT_EQ(1U, delegate_.GetRegisteredCallbackCount()); @@ -163,15 +161,16 @@ TEST_F(PepperDeviceEnumerationHostHelperTest, EnumerateDevices) { IPC::Message reply_msg; ASSERT_TRUE(sink_.GetFirstResourceReplyMatching( PpapiPluginMsg_DeviceEnumeration_EnumerateDevicesReply::ID, - &reply_params, &reply_msg)); + &reply_params, + &reply_msg)); EXPECT_EQ(call_params.sequence(), reply_params.sequence()); EXPECT_EQ(PP_OK, reply_params.result()); std::vector<ppapi::DeviceRefData> reply_data; ASSERT_TRUE(ppapi::UnpackMessage< - PpapiPluginMsg_DeviceEnumeration_EnumerateDevicesReply>( - reply_msg, &reply_data)); + PpapiPluginMsg_DeviceEnumeration_EnumerateDevicesReply>(reply_msg, + &reply_data)); EXPECT_EQ(data, reply_data); } @@ -225,8 +224,8 @@ TEST_F(PepperDeviceEnumerationHostHelperTest, MonitorDeviceChange) { resource_host_.pp_resource(), 123); ppapi::host::HostMessageContext context(call_params); int32_t result = PP_ERROR_FAILED; - ASSERT_TRUE(device_enumeration_.HandleResourceMessage( - msg, &context, &result)); + ASSERT_TRUE( + device_enumeration_.HandleResourceMessage(msg, &context, &result)); EXPECT_EQ(PP_OK, result); EXPECT_EQ(0U, delegate_.GetRegisteredCallbackCount()); diff --git a/content/renderer/pepper/pepper_file_chooser_host.cc b/content/renderer/pepper/pepper_file_chooser_host.cc index 3a10bd1..e65cc72 100644 --- a/content/renderer/pepper/pepper_file_chooser_host.cc +++ b/content/renderer/pepper/pepper_file_chooser_host.cc @@ -25,8 +25,7 @@ class PepperFileChooserHost::CompletionHandler : public blink::WebFileChooserCompletion { public: explicit CompletionHandler(const base::WeakPtr<PepperFileChooserHost>& host) - : host_(host) { - } + : host_(host) {} virtual ~CompletionHandler() {} @@ -50,8 +49,7 @@ class PepperFileChooserHost::CompletionHandler std::vector<PepperFileChooserHost::ChosenFileInfo> files; for (size_t i = 0; i < file_names.size(); i++) { files.push_back(PepperFileChooserHost::ChosenFileInfo( - file_names[i].path.utf8(), - file_names[i].displayName.utf8())); + file_names[i].path.utf8(), file_names[i].displayName.utf8())); } host_->StoreChosenFiles(files); } @@ -69,29 +67,23 @@ class PepperFileChooserHost::CompletionHandler PepperFileChooserHost::ChosenFileInfo::ChosenFileInfo( const std::string& path, const std::string& display_name) - : path(path), - display_name(display_name) { -} - + : path(path), display_name(display_name) {} -PepperFileChooserHost::PepperFileChooserHost( - RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) +PepperFileChooserHost::PepperFileChooserHost(RendererPpapiHost* host, + PP_Instance instance, + PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), handler_(NULL), - weak_factory_(this) { -} + weak_factory_(this) {} -PepperFileChooserHost::~PepperFileChooserHost() { -} +PepperFileChooserHost::~PepperFileChooserHost() {} int32_t PepperFileChooserHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperFileChooserHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileChooser_Show, OnShow) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileChooser_Show, OnShow) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -141,7 +133,7 @@ int32_t PepperFileChooserHost::OnShow( if (!host()->permissions().HasPermission( ppapi::PERMISSION_BYPASS_USER_GESTURE) && - !renderer_ppapi_host_->HasUserGesture(pp_instance())) { + !renderer_ppapi_host_->HasUserGesture(pp_instance())) { return PP_ERROR_NO_USER_GESTURE; } @@ -155,8 +147,8 @@ int32_t PepperFileChooserHost::OnShow( } std::vector<blink::WebString> mine_types(accept_mime_types.size()); for (size_t i = 0; i < accept_mime_types.size(); i++) { - mine_types[i] = blink::WebString::fromUTF8( - accept_mime_types[i].data(), accept_mime_types[i].size()); + mine_types[i] = blink::WebString::fromUTF8(accept_mime_types[i].data(), + accept_mime_types[i].size()); } params.acceptTypes = mine_types; params.directory = false; @@ -183,11 +175,8 @@ void PepperFileChooserHost::DidCreateResourceHosts( std::vector<ppapi::FileRefCreateInfo> chosen_files; for (size_t i = 0; i < browser_ids.size(); ++i) { - PepperFileRefRendererHost* renderer_host = - new PepperFileRefRendererHost(renderer_ppapi_host_, - pp_instance(), - 0, - file_paths[i]); + PepperFileRefRendererHost* renderer_host = new PepperFileRefRendererHost( + renderer_ppapi_host_, pp_instance(), 0, file_paths[i]); int renderer_id = renderer_ppapi_host_->GetPpapiHost()->AddPendingResourceHost( scoped_ptr<ppapi::host::ResourceHost>(renderer_host)); @@ -204,4 +193,3 @@ void PepperFileChooserHost::DidCreateResourceHosts( } } // namespace content - diff --git a/content/renderer/pepper/pepper_file_chooser_host_unittest.cc b/content/renderer/pepper/pepper_file_chooser_host_unittest.cc index 9f4a758..3868b54 100644 --- a/content/renderer/pepper/pepper_file_chooser_host_unittest.cc +++ b/content/renderer/pepper/pepper_file_chooser_host_unittest.cc @@ -31,8 +31,7 @@ namespace { class PepperFileChooserHostTest : public RenderViewTest { public: - PepperFileChooserHostTest() - : pp_instance_(123456) {} + PepperFileChooserHostTest() : pp_instance_(123456) {} virtual void SetUp() { SetContentClient(&client_); @@ -121,8 +120,8 @@ TEST_F(PepperFileChooserHostTest, Show) { EXPECT_EQ(call_params.sequence(), reply_params.sequence()); EXPECT_EQ(PP_OK, reply_params.result()); PpapiPluginMsg_FileChooser_ShowReply::Schema::Param reply_msg_param; - ASSERT_TRUE(PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, - &reply_msg_param)); + ASSERT_TRUE( + PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, &reply_msg_param)); const std::vector<ppapi::FileRefCreateInfo>& chooser_results = reply_msg_param.a; ASSERT_EQ(1u, chooser_results.size()); diff --git a/content/renderer/pepper/pepper_file_ref_renderer_host.cc b/content/renderer/pepper/pepper_file_ref_renderer_host.cc index 0f1442b..386f53e 100644 --- a/content/renderer/pepper/pepper_file_ref_renderer_host.cc +++ b/content/renderer/pepper/pepper_file_ref_renderer_host.cc @@ -43,8 +43,7 @@ PepperFileRefRendererHost::PepperFileRefRendererHost( file_system_type_ = PP_FILESYSTEMTYPE_INVALID; } -PepperFileRefRendererHost::~PepperFileRefRendererHost() { -} +PepperFileRefRendererHost::~PepperFileRefRendererHost() {} PP_FileSystemType PepperFileRefRendererHost::GetFileSystemType() const { return file_system_type_; @@ -69,15 +68,13 @@ base::FilePath PepperFileRefRendererHost::GetExternalFilePath() const { } int32_t PepperFileRefRendererHost::OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) { + const IPC::Message& msg, + ppapi::host::HostMessageContext* context) { // We don't handle any messages from the plugin in this host. NOTREACHED(); return PP_ERROR_FAILED; } -bool PepperFileRefRendererHost::IsFileRefHost() { - return true; -} +bool PepperFileRefRendererHost::IsFileRefHost() { return true; } } // namespace content diff --git a/content/renderer/pepper/pepper_file_ref_renderer_host.h b/content/renderer/pepper/pepper_file_ref_renderer_host.h index 0e33816..9cfc65f 100644 --- a/content/renderer/pepper/pepper_file_ref_renderer_host.h +++ b/content/renderer/pepper/pepper_file_ref_renderer_host.h @@ -22,8 +22,7 @@ namespace content { -class PepperFileRefRendererHost - : public ppapi::host::ResourceHost { +class PepperFileRefRendererHost : public ppapi::host::ResourceHost { public: PepperFileRefRendererHost(RendererPpapiHost* host, PP_Instance instance, diff --git a/content/renderer/pepper/pepper_file_system_host.cc b/content/renderer/pepper/pepper_file_system_host.cc index 36000fd..2dc3403 100644 --- a/content/renderer/pepper/pepper_file_system_host.cc +++ b/content/renderer/pepper/pepper_file_system_host.cc @@ -33,8 +33,7 @@ PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, type_(type), opened_(false), called_open_(false), - weak_factory_(this) { -} + weak_factory_(this) {} PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, PP_Instance instance, @@ -47,29 +46,23 @@ PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, opened_(true), root_url_(root_url), called_open_(true), - weak_factory_(this) { -} + weak_factory_(this) {} -PepperFileSystemHost::~PepperFileSystemHost() { -} +PepperFileSystemHost::~PepperFileSystemHost() {} int32_t PepperFileSystemHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperFileSystemHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_FileSystem_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_FileSystem_InitIsolatedFileSystem, - OnHostMsgInitIsolatedFileSystem) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_Open, OnHostMsgOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL( + PpapiHostMsg_FileSystem_InitIsolatedFileSystem, + OnHostMsgInitIsolatedFileSystem) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } -bool PepperFileSystemHost::IsFileSystemHost() { - return true; -} +bool PepperFileSystemHost::IsFileSystemHost() { return true; } void PepperFileSystemHost::DidOpenFileSystem( const std::string& /* name_unused */, diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index 3204de2..6cce27e 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc @@ -56,29 +56,30 @@ const int64 kOffscreenCallbackDelayMs = 1000 / 30; // 30 fps // NULL to indicate it should be the entire image. If the rect is outside of // the image, this will do nothing and return false. bool ValidateAndConvertRect(const PP_Rect* rect, - int image_width, int image_height, + int image_width, + int image_height, gfx::Rect* dest) { if (!rect) { // Use the entire image area. *dest = gfx::Rect(0, 0, image_width, image_height); } else { // Validate the passed-in area. - if (rect->point.x < 0 || rect->point.y < 0 || - rect->size.width <= 0 || rect->size.height <= 0) + if (rect->point.x < 0 || rect->point.y < 0 || rect->size.width <= 0 || + rect->size.height <= 0) return false; // Check the max bounds, being careful of overflow. if (static_cast<int64>(rect->point.x) + - static_cast<int64>(rect->size.width) > + static_cast<int64>(rect->size.width) > static_cast<int64>(image_width)) return false; if (static_cast<int64>(rect->point.y) + - static_cast<int64>(rect->size.height) > + static_cast<int64>(rect->size.height) > static_cast<int64>(image_height)) return false; - *dest = gfx::Rect(rect->point.x, rect->point.y, - rect->size.width, rect->size.height); + *dest = gfx::Rect( + rect->point.x, rect->point.y, rect->size.width, rect->size.height); } return true; } @@ -101,8 +102,10 @@ void ConvertBetweenBGRAandRGBA(const uint32_t* input, // Converts ImageData from PP_IMAGEDATAFORMAT_BGRA_PREMUL to // PP_IMAGEDATAFORMAT_RGBA_PREMUL, or reverse. It's assumed that the // destination image is always mapped (so will have non-NULL data). -void ConvertImageData(PPB_ImageData_Impl* src_image, const SkIRect& src_rect, - PPB_ImageData_Impl* dest_image, const SkRect& dest_rect) { +void ConvertImageData(PPB_ImageData_Impl* src_image, + const SkIRect& src_rect, + PPB_ImageData_Impl* dest_image, + const SkRect& dest_rect) { ImageDataAutoMapper auto_mapper(src_image); DCHECK(src_image->format() != dest_image->format()); @@ -136,19 +139,10 @@ void ConvertImageData(PPB_ImageData_Impl* src_image, const SkIRect& src_rect, } // namespace struct PepperGraphics2DHost::QueuedOperation { - enum Type { - PAINT, - SCROLL, - REPLACE, - }; + enum Type { PAINT, SCROLL, REPLACE, }; QueuedOperation(Type t) - : type(t), - paint_x(0), - paint_y(0), - scroll_dx(0), - scroll_dy(0) { - } + : type(t), paint_x(0), paint_y(0), scroll_dx(0), scroll_dy(0) {} Type type; @@ -175,7 +169,8 @@ PepperGraphics2DHost* PepperGraphics2DHost::Create( scoped_refptr<PPB_ImageData_Impl> backing_store) { PepperGraphics2DHost* resource_host = new PepperGraphics2DHost(host, instance, resource); - if (!resource_host->Init(size.width, size.height, + if (!resource_host->Init(size.width, + size.height, PP_ToBool(is_always_opaque), backing_store)) { delete resource_host; @@ -211,7 +206,9 @@ bool PepperGraphics2DHost::Init( // The underlying PPB_ImageData_Impl will validate the dimensions. image_data_ = backing_store; if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(), - width, height, true) || + width, + height, + true) || !image_data_->Map()) { image_data_ = NULL; return false; @@ -225,31 +222,23 @@ int32_t PepperGraphics2DHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperGraphics2DHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_Graphics2D_PaintImageData, - OnHostMsgPaintImageData) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_Graphics2D_Scroll, - OnHostMsgScroll) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_Graphics2D_ReplaceContents, - OnHostMsgReplaceContents) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_Graphics2D_Flush, - OnHostMsgFlush) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_Graphics2D_SetScale, - OnHostMsgSetScale) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_Graphics2D_ReadImageData, - OnHostMsgReadImageData) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_PaintImageData, + OnHostMsgPaintImageData) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_Scroll, + OnHostMsgScroll) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReplaceContents, + OnHostMsgReplaceContents) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Graphics2D_Flush, + OnHostMsgFlush) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetScale, + OnHostMsgSetScale) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData, + OnHostMsgReadImageData) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } -bool PepperGraphics2DHost::IsGraphics2DHost() { - return true; -} +bool PepperGraphics2DHost::IsGraphics2DHost() { return true; } bool PepperGraphics2DHost::ReadImageData(PP_Resource image, const PP_Point* top_left) { @@ -259,33 +248,30 @@ bool PepperGraphics2DHost::ReadImageData(PP_Resource image, return false; PPB_ImageData_Impl* image_resource = static_cast<PPB_ImageData_Impl*>(enter.object()); - if (!PPB_ImageData_Impl::IsImageDataFormatSupported( - image_resource->format())) + if (!PPB_ImageData_Impl::IsImageDataFormatSupported(image_resource->format())) return false; // Must be in the right format. // Validate the bitmap position. int x = top_left->x; if (x < 0 || static_cast<int64>(x) + static_cast<int64>(image_resource->width()) > - image_data_->width()) + image_data_->width()) return false; int y = top_left->y; if (y < 0 || static_cast<int64>(y) + static_cast<int64>(image_resource->height()) > - image_data_->height()) + image_data_->height()) return false; ImageDataAutoMapper auto_mapper(image_resource); if (!auto_mapper.is_valid()) return false; - SkIRect src_irect = { x, y, - x + image_resource->width(), - y + image_resource->height() }; - SkRect dest_rect = { SkIntToScalar(0), - SkIntToScalar(0), - SkIntToScalar(image_resource->width()), - SkIntToScalar(image_resource->height()) }; + SkIRect src_irect = {x, y, x + image_resource->width(), + y + image_resource->height()}; + SkRect dest_rect = {SkIntToScalar(0), SkIntToScalar(0), + SkIntToScalar(image_resource->width()), + SkIntToScalar(image_resource->height())}; if (image_resource->format() != image_data_->format()) { // Convert the image data if the format does not match. @@ -296,8 +282,8 @@ bool PepperGraphics2DHost::ReadImageData(PP_Resource image, // We want to replace the contents of the bitmap rather than blend. SkPaint paint; paint.setXfermodeMode(SkXfermode::kSrc_Mode); - dest_canvas->drawBitmapRect(*image_data_->GetMappedBitmap(), - &src_irect, dest_rect, &paint); + dest_canvas->drawBitmapRect( + *image_data_->GetMappedBitmap(), &src_irect, dest_rect, &paint); } return true; } @@ -344,8 +330,8 @@ void PepperGraphics2DHost::Paint(blink::WebCanvas* canvas, SkAutoCanvasRestore auto_restore(canvas, true); canvas->clipRect(sk_invalidate_rect); gfx::Size pixel_image_size(image_data_->width(), image_data_->height()); - gfx::Size image_size = gfx::ToFlooredSize( - gfx::ScaleSize(pixel_image_size, scale_)); + gfx::Size image_size = + gfx::ToFlooredSize(gfx::ScaleSize(pixel_image_size, scale_)); PepperPluginInstance* plugin_instance = renderer_ppapi_host_->GetPluginInstance(pp_instance()); @@ -397,8 +383,7 @@ void PepperGraphics2DHost::Paint(blink::WebCanvas* canvas, canvas->drawBitmap(image, pixel_origin.x(), pixel_origin.y(), &paint); } -void PepperGraphics2DHost::ViewInitiatedPaint() { -} +void PepperGraphics2DHost::ViewInitiatedPaint() {} void PepperGraphics2DHost::ViewFlushedPaint() { TRACE_EVENT0("pepper", "PepperGraphics2DHost::ViewFlushedPaint"); @@ -408,17 +393,11 @@ void PepperGraphics2DHost::ViewFlushedPaint() { } } -void PepperGraphics2DHost::SetScale(float scale) { - scale_ = scale; -} +void PepperGraphics2DHost::SetScale(float scale) { scale_ = scale; } -float PepperGraphics2DHost::GetScale() const { - return scale_; -} +float PepperGraphics2DHost::GetScale() const { return scale_; } -bool PepperGraphics2DHost::IsAlwaysOpaque() const { - return is_always_opaque_; -} +bool PepperGraphics2DHost::IsAlwaysOpaque() const { return is_always_opaque_; } PPB_ImageData_Impl* PepperGraphics2DHost::ImageData() { return image_data_.get(); @@ -457,11 +436,11 @@ int32_t PepperGraphics2DHost::OnHostMsgPaintImageData( int64 y64 = static_cast<int64>(top_left.y); if (x64 + static_cast<int64>(operation.paint_src_rect.x()) < 0 || x64 + static_cast<int64>(operation.paint_src_rect.right()) > - image_data_->width()) + image_data_->width()) return PP_ERROR_BADARGUMENT; if (y64 + static_cast<int64>(operation.paint_src_rect.y()) < 0 || y64 + static_cast<int64>(operation.paint_src_rect.bottom()) > - image_data_->height()) + image_data_->height()) return PP_ERROR_BADARGUMENT; operation.paint_x = top_left.x; operation.paint_y = top_left.y; @@ -507,8 +486,7 @@ int32_t PepperGraphics2DHost::OnHostMsgReplaceContents( PPB_ImageData_Impl* image_resource = static_cast<PPB_ImageData_Impl*>(enter.object()); - if (!PPB_ImageData_Impl::IsImageDataFormatSupported( - image_resource->format())) + if (!PPB_ImageData_Impl::IsImageDataFormatSupported(image_resource->format())) return PP_ERROR_BADARGUMENT; if (image_resource->width() != image_data_->width() || @@ -540,8 +518,7 @@ int32_t PepperGraphics2DHost::OnHostMsgFlush( // it back to the plugin for possible re-use. See ppb_image_data_proxy.cc // for a description how this process works. ppapi::HostResource old_image_data_host_resource; - old_image_data_host_resource.SetHostResource(pp_instance(), - old_image_data); + old_image_data_host_resource.SetHostResource(pp_instance(), old_image_data); host()->Send(new PpapiMsg_PPBImageData_NotifyUnusedImageData( ppapi::API_ID_PPB_IMAGE_DATA, old_image_data_host_resource)); } @@ -618,7 +595,8 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { break; case QueuedOperation::SCROLL: ExecuteScroll(operation.scroll_clip_rect, - operation.scroll_dx, operation.scroll_dy, + operation.scroll_dx, + operation.scroll_dy, &op_rect); break; case QueuedOperation::REPLACE: @@ -643,8 +621,9 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { gfx::Point scroll_delta(operation.scroll_dx, operation.scroll_dy); if (!ConvertToLogicalPixels(scale_, &op_rect, - operation.type == QueuedOperation::SCROLL ? - &scroll_delta : NULL)) { + operation.type == QueuedOperation::SCROLL + ? &scroll_delta + : NULL)) { // Conversion requires falling back to InvalidateRect. operation.type = QueuedOperation::PAINT; } @@ -661,8 +640,8 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { // Notify the plugin of the entire change (op_rect), even if it is // partially or completely off-screen. if (operation.type == QueuedOperation::SCROLL) { - bound_instance_->ScrollRect(scroll_delta.x(), scroll_delta.y(), - op_rect); + bound_instance_->ScrollRect( + scroll_delta.x(), scroll_delta.y(), op_rect); } else { if (!op_rect.IsEmpty()) bound_instance_->InvalidateRect(op_rect); @@ -688,25 +667,26 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { } void PepperGraphics2DHost::ExecutePaintImageData(PPB_ImageData_Impl* image, - int x, int y, - const gfx::Rect& src_rect, - gfx::Rect* invalidated_rect) { + int x, + int y, + const gfx::Rect& src_rect, + gfx::Rect* invalidated_rect) { // Ensure the source image is mapped to read from it. ImageDataAutoMapper auto_mapper(image); if (!auto_mapper.is_valid()) return; // Portion within the source image to cut out. - SkIRect src_irect = { src_rect.x(), src_rect.y(), - src_rect.right(), src_rect.bottom() }; + SkIRect src_irect = {src_rect.x(), src_rect.y(), src_rect.right(), + src_rect.bottom()}; // Location within the backing store to copy to. *invalidated_rect = src_rect; invalidated_rect->Offset(x, y); - SkRect dest_rect = { SkIntToScalar(invalidated_rect->x()), - SkIntToScalar(invalidated_rect->y()), - SkIntToScalar(invalidated_rect->right()), - SkIntToScalar(invalidated_rect->bottom()) }; + SkRect dest_rect = {SkIntToScalar(invalidated_rect->x()), + SkIntToScalar(invalidated_rect->y()), + SkIntToScalar(invalidated_rect->right()), + SkIntToScalar(invalidated_rect->bottom())}; if (image->format() != image_data_->format()) { // Convert the image data if the format does not match. @@ -718,31 +698,30 @@ void PepperGraphics2DHost::ExecutePaintImageData(PPB_ImageData_Impl* image, // We want to replace the contents of the bitmap rather than blend. SkPaint paint; paint.setXfermodeMode(SkXfermode::kSrc_Mode); - backing_canvas->drawBitmapRect(*image->GetMappedBitmap(), - &src_irect, dest_rect, &paint); + backing_canvas->drawBitmapRect( + *image->GetMappedBitmap(), &src_irect, dest_rect, &paint); } } void PepperGraphics2DHost::ExecuteScroll(const gfx::Rect& clip, - int dx, int dy, - gfx::Rect* invalidated_rect) { - gfx::ScrollCanvas(image_data_->GetCanvas(), - clip, gfx::Vector2d(dx, dy)); + int dx, + int dy, + gfx::Rect* invalidated_rect) { + gfx::ScrollCanvas(image_data_->GetCanvas(), clip, gfx::Vector2d(dx, dy)); *invalidated_rect = clip; } void PepperGraphics2DHost::ExecuteReplaceContents(PPB_ImageData_Impl* image, - gfx::Rect* invalidated_rect, - PP_Resource* old_image_data) { + gfx::Rect* invalidated_rect, + PP_Resource* old_image_data) { if (image->format() != image_data_->format()) { DCHECK(image->width() == image_data_->width() && image->height() == image_data_->height()); // Convert the image data if the format does not match. - SkIRect src_irect = { 0, 0, image->width(), image->height() }; - SkRect dest_rect = { SkIntToScalar(0), - SkIntToScalar(0), - SkIntToScalar(image_data_->width()), - SkIntToScalar(image_data_->height()) }; + SkIRect src_irect = {0, 0, image->width(), image->height()}; + SkRect dest_rect = {SkIntToScalar(0), SkIntToScalar(0), + SkIntToScalar(image_data_->width()), + SkIntToScalar(image_data_->height())}; ConvertImageData(image, src_irect, image_data_.get(), dest_rect); } else { // The passed-in image may not be mapped in our process, and we need to @@ -754,13 +733,12 @@ void PepperGraphics2DHost::ExecuteReplaceContents(PPB_ImageData_Impl* image, *old_image_data = image_data_->GetReference(); image_data_ = image; } - *invalidated_rect = gfx::Rect(0, 0, - image_data_->width(), image_data_->height()); + *invalidated_rect = + gfx::Rect(0, 0, image_data_->width(), image_data_->height()); } void PepperGraphics2DHost::SendFlushAck() { - host()->SendReply(flush_reply_context_, - PpapiPluginMsg_Graphics2D_FlushAck()); + host()->SendReply(flush_reply_context_, PpapiPluginMsg_Graphics2D_FlushAck()); } void PepperGraphics2DHost::SendOffscreenFlushAck() { @@ -777,8 +755,7 @@ void PepperGraphics2DHost::ScheduleOffscreenFlushAck() { offscreen_flush_pending_ = true; base::MessageLoop::current()->PostDelayedTask( FROM_HERE, - base::Bind(&PepperGraphics2DHost::SendOffscreenFlushAck, - AsWeakPtr()), + base::Bind(&PepperGraphics2DHost::SendOffscreenFlushAck, AsWeakPtr()), base::TimeDelta::FromMilliseconds(kOffscreenCallbackDelayMs)); } @@ -788,8 +765,8 @@ bool PepperGraphics2DHost::HasPendingFlush() const { // static bool PepperGraphics2DHost::ConvertToLogicalPixels(float scale, - gfx::Rect* op_rect, - gfx::Point* delta) { + gfx::Rect* op_rect, + gfx::Point* delta) { if (scale == 1.0f || scale <= 0.0f) return true; diff --git a/content/renderer/pepper/pepper_graphics_2d_host.h b/content/renderer/pepper/pepper_graphics_2d_host.h index ce5a1af..71eb59f 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.h +++ b/content/renderer/pepper/pepper_graphics_2d_host.h @@ -57,8 +57,7 @@ class CONTENT_EXPORT PepperGraphics2DHost ppapi::host::HostMessageContext* context) OVERRIDE; virtual bool IsGraphics2DHost() OVERRIDE; - bool ReadImageData(PP_Resource image, - const PP_Point* top_left); + bool ReadImageData(PP_Resource image, const PP_Point* top_left); // Assciates this device with the given plugin instance. You can pass NULL // to clear the existing device. Returns true on success. In this case, a // repaint of the page will also be scheduled. Failure means that the device @@ -123,10 +122,13 @@ class CONTENT_EXPORT PepperGraphics2DHost // the update that requires invalidation. If there were no pixels changed, // this rect can be untouched. void ExecutePaintImageData(PPB_ImageData_Impl* image, - int x, int y, + int x, + int y, const gfx::Rect& src_rect, gfx::Rect* invalidated_rect); - void ExecuteScroll(const gfx::Rect& clip, int dx, int dy, + void ExecuteScroll(const gfx::Rect& clip, + int dx, + int dy, gfx::Rect* invalidated_rect); void ExecuteReplaceContents(PPB_ImageData_Impl* image, gfx::Rect* invalidated_rect, diff --git a/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc b/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc index 902d21d..d16c863 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc @@ -44,9 +44,12 @@ class PepperGraphics2DHostTest : public testing::Test { test_globals_.GetResourceTracker()->DidCreateInstance(instance); scoped_refptr<PPB_ImageData_Impl> backing_store( new PPB_ImageData_Impl(instance, PPB_ImageData_Impl::ForTest())); - host_.reset(PepperGraphics2DHost::Create( - &renderer_ppapi_host_, instance, 12345, backing_store_size, PP_FALSE, - backing_store)); + host_.reset(PepperGraphics2DHost::Create(&renderer_ppapi_host_, + instance, + 12345, + backing_store_size, + PP_FALSE, + backing_store)); DCHECK(host_.get()); } @@ -54,8 +57,8 @@ class PepperGraphics2DHostTest : public testing::Test { ppapi::HostResource image_data_resource; image_data_resource.SetHostResource(image_data->pp_instance(), image_data->pp_resource()); - host_->OnHostMsgPaintImageData(NULL, image_data_resource, - PP_Point(), false, PP_Rect()); + host_->OnHostMsgPaintImageData( + NULL, image_data_resource, PP_Point(), false, PP_Rect()); } void Flush() { @@ -69,7 +72,8 @@ class PepperGraphics2DHostTest : public testing::Test { void PaintToWebCanvas(SkBitmap* bitmap) { scoped_ptr<WebCanvas> canvas(new WebCanvas(*bitmap)); gfx::Rect plugin_rect(PP_ToGfxRect(renderer_view_data_.rect)); - host_->Paint(canvas.get(), plugin_rect, + host_->Paint(canvas.get(), + plugin_rect, gfx::Rect(0, 0, plugin_rect.width(), plugin_rect.height())); } @@ -109,41 +113,39 @@ TEST_F(PepperGraphics2DHostTest, ConvertToLogicalPixels) { int dy2; float scale; bool result; - } tests[] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, true }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.0, true }, - { 0, 0, 4, 4, 0, 0, 2, 2, 0, 0, 0, 0, 0.5, true }, - { 1, 1, 4, 4, 0, 0, 3, 3, 0, 0, 0, 0, 0.5, false }, - { 53, 75, 100, 100, 53, 75, 100, 100, 0, 0, 0, 0, 1.0, true }, - { 53, 75, 100, 100, 106, 150, 200, 200, 0, 0, 0, 0, 2.0, true }, - { 53, 75, 100, 100, 26, 37, 51, 51, 0, 0, 0, 0, 0.5, false }, - { 53, 74, 100, 100, 26, 37, 51, 50, 0, 0, 0, 0, 0.5, false }, - { -1, -1, 100, 100, -1, -1, 51, 51, 0, 0, 0, 0, 0.5, false }, - { -2, -2, 100, 100, -1, -1, 50, 50, 4, -4, 2, -2, 0.5, true }, - { -101, -100, 50, 50, -51, -50, 26, 25, 0, 0, 0, 0, 0.5, false }, - { 10, 10, 20, 20, 5, 5, 10, 10, 0, 0, 0, 0, 0.5, true }, - // Cannot scroll due to partial coverage on sides - { 11, 10, 20, 20, 5, 5, 11, 10, 0, 0, 0, 0, 0.5, false }, - // Can scroll since backing store is actually smaller/scaling up - { 11, 20, 100, 100, 22, 40, 200, 200, 7, 3, 14, 6, 2.0, true }, - // Can scroll due to delta and bounds being aligned - { 10, 10, 20, 20, 5, 5, 10, 10, 6, 4, 3, 2, 0.5, true }, - // Cannot scroll due to dx - { 10, 10, 20, 20, 5, 5, 10, 10, 5, 4, 2, 2, 0.5, false }, - // Cannot scroll due to dy - { 10, 10, 20, 20, 5, 5, 10, 10, 6, 3, 3, 1, 0.5, false }, - // Cannot scroll due to top - { 10, 11, 20, 20, 5, 5, 10, 11, 6, 4, 3, 2, 0.5, false }, - // Cannot scroll due to left - { 7, 10, 20, 20, 3, 5, 11, 10, 6, 4, 3, 2, 0.5, false }, - // Cannot scroll due to width - { 10, 10, 21, 20, 5, 5, 11, 10, 6, 4, 3, 2, 0.5, false }, - // Cannot scroll due to height - { 10, 10, 20, 51, 5, 5, 10, 26, 6, 4, 3, 2, 0.5, false }, - // Check negative scroll deltas - { 10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true }, - { 10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false }, - }; + } tests[] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, true}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.0, true}, + {0, 0, 4, 4, 0, 0, 2, 2, 0, 0, 0, 0, 0.5, true}, + {1, 1, 4, 4, 0, 0, 3, 3, 0, 0, 0, 0, 0.5, false}, + {53, 75, 100, 100, 53, 75, 100, 100, 0, 0, 0, 0, 1.0, true}, + {53, 75, 100, 100, 106, 150, 200, 200, 0, 0, 0, 0, 2.0, true}, + {53, 75, 100, 100, 26, 37, 51, 51, 0, 0, 0, 0, 0.5, false}, + {53, 74, 100, 100, 26, 37, 51, 50, 0, 0, 0, 0, 0.5, false}, + {-1, -1, 100, 100, -1, -1, 51, 51, 0, 0, 0, 0, 0.5, false}, + {-2, -2, 100, 100, -1, -1, 50, 50, 4, -4, 2, -2, 0.5, true}, + {-101, -100, 50, 50, -51, -50, 26, 25, 0, 0, 0, 0, 0.5, false}, + {10, 10, 20, 20, 5, 5, 10, 10, 0, 0, 0, 0, 0.5, true}, + // Cannot scroll due to partial coverage on sides + {11, 10, 20, 20, 5, 5, 11, 10, 0, 0, 0, 0, 0.5, false}, + // Can scroll since backing store is actually smaller/scaling up + {11, 20, 100, 100, 22, 40, 200, 200, 7, 3, 14, 6, 2.0, true}, + // Can scroll due to delta and bounds being aligned + {10, 10, 20, 20, 5, 5, 10, 10, 6, 4, 3, 2, 0.5, true}, + // Cannot scroll due to dx + {10, 10, 20, 20, 5, 5, 10, 10, 5, 4, 2, 2, 0.5, false}, + // Cannot scroll due to dy + {10, 10, 20, 20, 5, 5, 10, 10, 6, 3, 3, 1, 0.5, false}, + // Cannot scroll due to top + {10, 11, 20, 20, 5, 5, 10, 11, 6, 4, 3, 2, 0.5, false}, + // Cannot scroll due to left + {7, 10, 20, 20, 3, 5, 11, 10, 6, 4, 3, 2, 0.5, false}, + // Cannot scroll due to width + {10, 10, 21, 20, 5, 5, 11, 10, 6, 4, 3, 2, 0.5, false}, + // Cannot scroll due to height + {10, 10, 20, 51, 5, 5, 10, 26, 6, 4, 3, 2, 0.5, false}, + // Check negative scroll deltas + {10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true}, + {10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); diff --git a/content/renderer/pepper/pepper_hung_plugin_filter.cc b/content/renderer/pepper/pepper_hung_plugin_filter.cc index ba4af0e..57fc4a6 100644 --- a/content/renderer/pepper/pepper_hung_plugin_filter.cc +++ b/content/renderer/pepper/pepper_hung_plugin_filter.cc @@ -35,8 +35,7 @@ PepperHungPluginFilter::PepperHungPluginFilter( io_loop_(ChildProcess::current()->io_message_loop_proxy()), pending_sync_message_count_(0), hung_plugin_showing_(false), - timer_task_pending_(false) { -} + timer_task_pending_(false) {} void PepperHungPluginFilter::BeginBlockOnSyncMessage() { base::AutoLock lock(lock_); @@ -56,8 +55,7 @@ void PepperHungPluginFilter::EndBlockOnSyncMessage() { MayHaveBecomeUnhung(); } -void PepperHungPluginFilter::OnFilterAdded(IPC::Channel* channel) { -} +void PepperHungPluginFilter::OnFilterAdded(IPC::Channel* channel) {} void PepperHungPluginFilter::OnFilterRemoved() { base::AutoLock lock(lock_); @@ -85,7 +83,8 @@ void PepperHungPluginFilter::EnsureTimerScheduled() { return; timer_task_pending_ = true; - io_loop_->PostDelayedTask(FROM_HERE, + io_loop_->PostDelayedTask( + FROM_HERE, base::Bind(&PepperHungPluginFilter::OnHangTimer, this), base::TimeDelta::FromSeconds(kHungThresholdSec)); } @@ -107,12 +106,13 @@ base::TimeTicks PepperHungPluginFilter::GetHungTime() const { DCHECK(!last_message_received_.is_null()); // Always considered hung at the hard threshold. - base::TimeTicks hard_time = began_blocking_time_ + + base::TimeTicks hard_time = + began_blocking_time_ + base::TimeDelta::FromSeconds(kBlockedHardThresholdSec); // Hung after a soft threshold from last message of any sort. - base::TimeTicks soft_time = last_message_received_ + - base::TimeDelta::FromSeconds(kHungThresholdSec); + base::TimeTicks soft_time = + last_message_received_ + base::TimeDelta::FromSeconds(kHungThresholdSec); return std::min(soft_time, hard_time); } @@ -140,7 +140,8 @@ void PepperHungPluginFilter::OnHangTimer() { // would not have scheduled one (we only have one out-standing timer at // a time). timer_task_pending_ = true; - io_loop_->PostDelayedTask(FROM_HERE, + io_loop_->PostDelayedTask( + FROM_HERE, base::Bind(&PepperHungPluginFilter::OnHangTimer, this), delay); return; diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.cc b/content/renderer/pepper/pepper_in_process_resource_creation.cc index 23ed785..596f149 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.cc +++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc @@ -43,12 +43,9 @@ namespace content { PepperInProcessResourceCreation::PepperInProcessResourceCreation( RendererPpapiHostImpl* host_impl, PepperPluginInstanceImpl* instance) - : ResourceCreationImpl(instance), - host_impl_(host_impl) { -} + : ResourceCreationImpl(instance), host_impl_(host_impl) {} -PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { -} +PepperInProcessResourceCreation::~PepperInProcessResourceCreation() {} PP_Resource PepperInProcessResourceCreation::CreateBrowserFont( PP_Instance instance, @@ -58,10 +55,10 @@ PP_Resource PepperInProcessResourceCreation::CreateBrowserFont( ppapi::Preferences prefs( host_impl_->GetRenderViewForInstance(instance)->GetWebkitPreferences()); return (new BrowserFontResource_Trusted( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance, - *description, - prefs))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance, + *description, + prefs))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateFileChooser( @@ -72,17 +69,17 @@ PP_Resource PepperInProcessResourceCreation::CreateFileChooser( ppapi::StringVar::FromPPVar(accept_types); std::string str = string_var.get() ? string_var->value() : std::string(); return (new ppapi::proxy::FileChooserResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance, - mode, - str.c_str()))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance, + mode, + str.c_str()))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateFileIO( PP_Instance instance) { return (new ppapi::proxy::FileIOResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateFileRef( @@ -98,8 +95,9 @@ PP_Resource PepperInProcessResourceCreation::CreateFileSystem( PP_Instance instance, PP_FileSystemType type) { return (new ppapi::proxy::FileSystemResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance, type))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance, + type))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateGraphics2D( @@ -107,15 +105,17 @@ PP_Resource PepperInProcessResourceCreation::CreateGraphics2D( const PP_Size* size, PP_Bool is_always_opaque) { return (new ppapi::proxy::Graphics2DResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance, *size, is_always_opaque))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance, + *size, + is_always_opaque))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreatePrinting( PP_Instance instance) { return (new ppapi::proxy::PrintingResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateTrueTypeFont( @@ -128,22 +128,23 @@ PP_Resource PepperInProcessResourceCreation::CreateTrueTypeFont( PP_Resource PepperInProcessResourceCreation::CreateURLLoader( PP_Instance instance) { return (new ppapi::proxy::URLLoaderResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateURLRequestInfo( PP_Instance instance) { return (new ppapi::proxy::URLRequestInfoResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance, ppapi::URLRequestInfoData()))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance, + ppapi::URLRequestInfoData()))->GetReference(); } PP_Resource PepperInProcessResourceCreation::CreateWebSocket( PP_Instance instance) { return (new ppapi::proxy::WebSocketResource( - host_impl_->in_process_router()->GetPluginConnection(instance), - instance))->GetReference(); + host_impl_->in_process_router()->GetPluginConnection(instance), + instance))->GetReference(); } } // namespace content diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.h b/content/renderer/pepper/pepper_in_process_resource_creation.h index 847aac1..2718912 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.h +++ b/content/renderer/pepper/pepper_in_process_resource_creation.h @@ -44,31 +44,25 @@ class PepperInProcessResourceCreation : public ResourceCreationImpl { virtual PP_Resource CreateBrowserFont( PP_Instance instance, const PP_BrowserFont_Trusted_Description* description) OVERRIDE; - virtual PP_Resource CreateFileChooser( - PP_Instance instance, - PP_FileChooserMode_Dev mode, - const PP_Var& accept_types) OVERRIDE; + virtual PP_Resource CreateFileChooser(PP_Instance instance, + PP_FileChooserMode_Dev mode, + const PP_Var& accept_types) OVERRIDE; virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFileRef( - PP_Instance instance, - const ppapi::FileRefCreateInfo& create_info) OVERRIDE; + virtual PP_Resource CreateFileRef(PP_Instance instance, + const ppapi::FileRefCreateInfo& create_info) + OVERRIDE; virtual PP_Resource CreateFileSystem(PP_Instance instance, PP_FileSystemType type) OVERRIDE; - virtual PP_Resource CreateGraphics2D( - PP_Instance pp_instance, - const PP_Size* size, - PP_Bool is_always_opaque) OVERRIDE; - virtual PP_Resource CreatePrinting( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, + const PP_Size* size, + PP_Bool is_always_opaque) OVERRIDE; + virtual PP_Resource CreatePrinting(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTrueTypeFont( PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc) OVERRIDE; - virtual PP_Resource CreateURLLoader( - PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateURLRequestInfo( - PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateWebSocket( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateWebSocket(PP_Instance instance) OVERRIDE; private: // Non-owning pointer to the host for the current plugin. diff --git a/content/renderer/pepper/pepper_in_process_router.cc b/content/renderer/pepper/pepper_in_process_router.cc index 45755e1..9194f12 100644 --- a/content/renderer/pepper/pepper_in_process_router.cc +++ b/content/renderer/pepper/pepper_in_process_router.cc @@ -34,25 +34,20 @@ class PepperInProcessRouter::Channel : public IPC::Sender { base::Callback<bool(IPC::Message*)> callback_; }; -PepperInProcessRouter::PepperInProcessRouter( - RendererPpapiHostImpl* host_impl) +PepperInProcessRouter::PepperInProcessRouter(RendererPpapiHostImpl* host_impl) : host_impl_(host_impl), pending_message_id_(0), reply_result_(false), weak_factory_(this) { - browser_channel_.reset( - new Channel(base::Bind(&PepperInProcessRouter::SendToBrowser, - base::Unretained(this)))); - host_to_plugin_router_.reset( - new Channel(base::Bind(&PepperInProcessRouter::SendToPlugin, - base::Unretained(this)))); - plugin_to_host_router_.reset( - new Channel(base::Bind(&PepperInProcessRouter::SendToHost, - base::Unretained(this)))); + browser_channel_.reset(new Channel(base::Bind( + &PepperInProcessRouter::SendToBrowser, base::Unretained(this)))); + host_to_plugin_router_.reset(new Channel(base::Bind( + &PepperInProcessRouter::SendToPlugin, base::Unretained(this)))); + plugin_to_host_router_.reset(new Channel( + base::Bind(&PepperInProcessRouter::SendToHost, base::Unretained(this)))); } -PepperInProcessRouter::~PepperInProcessRouter() { -} +PepperInProcessRouter::~PepperInProcessRouter() {} IPC::Sender* PepperInProcessRouter::GetPluginToRendererSender() { return plugin_to_host_router_.get(); @@ -68,9 +63,8 @@ ppapi::proxy::Connection PepperInProcessRouter::GetPluginConnection( RenderFrame* frame = host_impl_->GetRenderFrameForInstance(instance); if (frame) routing_id = frame->GetRoutingID(); - return ppapi::proxy::Connection(browser_channel_.get(), - plugin_to_host_router_.get(), - routing_id); + return ppapi::proxy::Connection( + browser_channel_.get(), plugin_to_host_router_.get(), routing_id); } // static @@ -81,15 +75,15 @@ bool PepperInProcessRouter::OnPluginMsgReceived(const IPC::Message& msg) { if (msg.type() == PpapiPluginMsg_ResourceReply::ID) { // Resource reply from the renderer (no routing id). - if (!UnpackMessage<PpapiPluginMsg_ResourceReply>(msg, &reply_params, - &nested_msg)) { + if (!UnpackMessage<PpapiPluginMsg_ResourceReply>( + msg, &reply_params, &nested_msg)) { NOTREACHED(); return false; } } else if (msg.type() == PpapiHostMsg_InProcessResourceReply::ID) { // Resource reply from the browser (has a routing id). - if (!UnpackMessage<PpapiHostMsg_InProcessResourceReply>(msg, &reply_params, - &nested_msg)) { + if (!UnpackMessage<PpapiHostMsg_InProcessResourceReply>( + msg, &reply_params, &nested_msg)) { NOTREACHED(); return false; } @@ -171,7 +165,7 @@ void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) { DCHECK(handled); } -bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) { +bool PepperInProcessRouter::SendToBrowser(IPC::Message* msg) { return RenderThread::Get()->Send(msg); } diff --git a/content/renderer/pepper/pepper_in_process_router.h b/content/renderer/pepper/pepper_in_process_router.h index 77b1988..73865fc 100644 --- a/content/renderer/pepper/pepper_in_process_router.h +++ b/content/renderer/pepper/pepper_in_process_router.h @@ -69,11 +69,11 @@ class PepperInProcessRouter { static bool OnPluginMsgReceived(const IPC::Message& msg); private: - bool SendToHost(IPC::Message *msg); - bool SendToPlugin(IPC::Message *msg); + bool SendToHost(IPC::Message* msg); + bool SendToPlugin(IPC::Message* msg); void DispatchHostMsg(IPC::Message* msg); void DispatchPluginMsg(IPC::Message* msg); - bool SendToBrowser(IPC::Message *msg); + bool SendToBrowser(IPC::Message* msg); RendererPpapiHostImpl* host_impl_; diff --git a/content/renderer/pepper/pepper_media_device_manager.cc b/content/renderer/pepper/pepper_media_device_manager.cc index 23f794a..9ef815c 100644 --- a/content/renderer/pepper/pepper_media_device_manager.cc +++ b/content/renderer/pepper/pepper_media_device_manager.cc @@ -24,7 +24,7 @@ ppapi::DeviceRefData FromStreamDeviceInfo(const StreamDeviceInfo& info) { } // namespace PepperMediaDeviceManager* PepperMediaDeviceManager::GetForRenderView( - RenderView* render_view) { + RenderView* render_view) { PepperMediaDeviceManager* handler = PepperMediaDeviceManager::Get(render_view); if (!handler) @@ -35,8 +35,7 @@ PepperMediaDeviceManager* PepperMediaDeviceManager::GetForRenderView( PepperMediaDeviceManager::PepperMediaDeviceManager(RenderView* render_view) : RenderViewObserver(render_view), RenderViewObserverTracker<PepperMediaDeviceManager>(render_view), - next_id_(1) { -} + next_id_(1) {} PepperMediaDeviceManager::~PepperMediaDeviceManager() { DCHECK(enumerate_callbacks_.empty()); @@ -52,17 +51,17 @@ int PepperMediaDeviceManager::EnumerateDevices( #if defined(ENABLE_WEBRTC) GetRenderViewImpl()->media_stream_dispatcher()->EnumerateDevices( - request_id, AsWeakPtr(), + request_id, + AsWeakPtr(), PepperMediaDeviceManager::FromPepperDeviceType(type), document_url.GetOrigin()); #else base::MessageLoop::current()->PostTask( FROM_HERE, - base::Bind( - &PepperMediaDeviceManager::OnDevicesEnumerated, - AsWeakPtr(), - request_id, - StreamDeviceInfoArray())); + base::Bind(&PepperMediaDeviceManager::OnDevicesEnumerated, + AsWeakPtr(), + request_id, + StreamDeviceInfoArray())); #endif return request_id; @@ -83,22 +82,20 @@ void PepperMediaDeviceManager::StopEnumerateDevices(int request_id) { #endif } -int PepperMediaDeviceManager::OpenDevice( - PP_DeviceType_Dev type, - const std::string& device_id, - const GURL& document_url, - const OpenDeviceCallback& callback) { +int PepperMediaDeviceManager::OpenDevice(PP_DeviceType_Dev type, + const std::string& device_id, + const GURL& document_url, + const OpenDeviceCallback& callback) { open_callbacks_[next_id_] = callback; int request_id = next_id_++; #if defined(ENABLE_WEBRTC) - GetRenderViewImpl()->media_stream_dispatcher()-> - OpenDevice( - request_id, - AsWeakPtr(), - device_id, - PepperMediaDeviceManager::FromPepperDeviceType(type), - document_url.GetOrigin()); + GetRenderViewImpl()->media_stream_dispatcher()->OpenDevice( + request_id, + AsWeakPtr(), + device_id, + PepperMediaDeviceManager::FromPepperDeviceType(type), + document_url.GetOrigin()); #else base::MessageLoop::current()->PostTask( FROM_HERE, @@ -114,8 +111,8 @@ void PepperMediaDeviceManager::CancelOpenDevice(int request_id) { open_callbacks_.erase(request_id); #if defined(ENABLE_WEBRTC) - GetRenderViewImpl()->media_stream_dispatcher()->CancelOpenDevice( - request_id, AsWeakPtr()); + GetRenderViewImpl()->media_stream_dispatcher()->CancelOpenDevice(request_id, + AsWeakPtr()); #endif } @@ -148,18 +145,15 @@ void PepperMediaDeviceManager::OnStreamGenerated( int request_id, const std::string& label, const StreamDeviceInfoArray& audio_device_array, - const StreamDeviceInfoArray& video_device_array) { -} + const StreamDeviceInfoArray& video_device_array) {} void PepperMediaDeviceManager::OnStreamGenerationFailed( int request_id, - content::MediaStreamRequestResult result) { -} + content::MediaStreamRequestResult result) {} void PepperMediaDeviceManager::OnDeviceStopped( const std::string& label, - const StreamDeviceInfo& device_info) { -} + const StreamDeviceInfo& device_info) {} void PepperMediaDeviceManager::OnDevicesEnumerated( int request_id, @@ -175,8 +169,9 @@ void PepperMediaDeviceManager::OnDevicesEnumerated( std::vector<ppapi::DeviceRefData> devices; devices.reserve(device_array.size()); - for (StreamDeviceInfoArray::const_iterator info = - device_array.begin(); info != device_array.end(); ++info) { + for (StreamDeviceInfoArray::const_iterator info = device_array.begin(); + info != device_array.end(); + ++info) { devices.push_back(FromStreamDeviceInfo(*info)); } callback.Run(request_id, devices); @@ -225,10 +220,9 @@ PP_DeviceType_Dev PepperMediaDeviceManager::FromMediaStreamType( } } -void PepperMediaDeviceManager::NotifyDeviceOpened( - int request_id, - bool succeeded, - const std::string& label) { +void PepperMediaDeviceManager::NotifyDeviceOpened(int request_id, + bool succeeded, + const std::string& label) { OpenCallbackMap::iterator iter = open_callbacks_.find(request_id); if (iter == open_callbacks_.end()) { // The callback may have been unregistered. diff --git a/content/renderer/pepper/pepper_media_device_manager.h b/content/renderer/pepper/pepper_media_device_manager.h index 86920f0..6fa7d7a 100644 --- a/content/renderer/pepper/pepper_media_device_manager.h +++ b/content/renderer/pepper/pepper_media_device_manager.h @@ -27,15 +27,15 @@ class PepperMediaDeviceManager virtual ~PepperMediaDeviceManager(); // PepperDeviceEnumerationHostHelper::Delegate implementation: - virtual int EnumerateDevices( - PP_DeviceType_Dev type, - const GURL& document_url, - const EnumerateDevicesCallback& callback) OVERRIDE; + virtual int EnumerateDevices(PP_DeviceType_Dev type, + const GURL& document_url, + const EnumerateDevicesCallback& callback) + OVERRIDE; virtual void StopEnumerateDevices(int request_id) OVERRIDE; - typedef base::Callback<void (int /* request_id */, - bool /* succeeded */, - const std::string& /* label */)> + typedef base::Callback<void(int /* request_id */, + bool /* succeeded */, + const std::string& /* label */)> OpenDeviceCallback; // Opens the specified device. The request ID passed into the callback will be @@ -65,13 +65,12 @@ class PepperMediaDeviceManager content::MediaStreamRequestResult result) OVERRIDE; virtual void OnDeviceStopped(const std::string& label, const StreamDeviceInfo& device_info) OVERRIDE; - virtual void OnDevicesEnumerated( - int request_id, - const StreamDeviceInfoArray& device_array) OVERRIDE; - virtual void OnDeviceOpened( - int request_id, - const std::string& label, - const StreamDeviceInfo& device_info) OVERRIDE; + virtual void OnDevicesEnumerated(int request_id, + const StreamDeviceInfoArray& device_array) + OVERRIDE; + virtual void OnDeviceOpened(int request_id, + const std::string& label, + const StreamDeviceInfo& device_info) OVERRIDE; virtual void OnDeviceOpenFailed(int request_id) OVERRIDE; // Stream type conversion. diff --git a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc index e0981c0..f7ca253 100644 --- a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc +++ b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc @@ -27,15 +27,24 @@ const int32_t kNumberOfBuffers = 4; // |PP_AudioBuffer_SampleRate|, otherwise false. PP_AudioBuffer_SampleRate GetPPSampleRate(int sample_rate) { switch (sample_rate) { - case 8000: return PP_AUDIOBUFFER_SAMPLERATE_8000; - case 16000: return PP_AUDIOBUFFER_SAMPLERATE_16000; - case 22050: return PP_AUDIOBUFFER_SAMPLERATE_22050; - case 32000: return PP_AUDIOBUFFER_SAMPLERATE_32000; - case 44100: return PP_AUDIOBUFFER_SAMPLERATE_44100; - case 48000: return PP_AUDIOBUFFER_SAMPLERATE_48000; - case 96000: return PP_AUDIOBUFFER_SAMPLERATE_96000; - case 192000: return PP_AUDIOBUFFER_SAMPLERATE_192000; - default: return PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN; + case 8000: + return PP_AUDIOBUFFER_SAMPLERATE_8000; + case 16000: + return PP_AUDIOBUFFER_SAMPLERATE_16000; + case 22050: + return PP_AUDIOBUFFER_SAMPLERATE_22050; + case 32000: + return PP_AUDIOBUFFER_SAMPLERATE_32000; + case 44100: + return PP_AUDIOBUFFER_SAMPLERATE_44100; + case 48000: + return PP_AUDIOBUFFER_SAMPLERATE_48000; + case 96000: + return PP_AUDIOBUFFER_SAMPLERATE_96000; + case 192000: + return PP_AUDIOBUFFER_SAMPLERATE_192000; + default: + return PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN; } } @@ -48,8 +57,7 @@ PepperMediaStreamAudioTrackHost::AudioSink::AudioSink( : host_(host), buffer_data_size_(0), main_message_loop_proxy_(base::MessageLoopProxy::current()), - weak_factory_(this) { -} + weak_factory_(this) {} PepperMediaStreamAudioTrackHost::AudioSink::~AudioSink() { DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); @@ -64,7 +72,8 @@ void PepperMediaStreamAudioTrackHost::AudioSink::EnqueueBuffer(int32_t index) { } void PepperMediaStreamAudioTrackHost::AudioSink::InitBuffersOnMainThread( - int32_t number_of_buffers, int32_t buffer_size) { + int32_t number_of_buffers, + int32_t buffer_size) { DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); bool result = host_->InitBuffers(number_of_buffers, buffer_size); // TODO(penghuang): Send PP_ERROR_NOMEMORY to plugin. @@ -77,8 +86,7 @@ void PepperMediaStreamAudioTrackHost::AudioSink::InitBuffersOnMainThread( } } -void -PepperMediaStreamAudioTrackHost::AudioSink:: +void PepperMediaStreamAudioTrackHost::AudioSink:: SendEnqueueBufferMessageOnMainThread(int32_t index) { DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); host_->SendEnqueueBufferMessageToPlugin(index); @@ -118,7 +126,8 @@ void PepperMediaStreamAudioTrackHost::AudioSink::OnData(const int16* audio_data, main_message_loop_proxy_->PostTask( FROM_HERE, base::Bind(&AudioSink::SendEnqueueBufferMessageOnMainThread, - weak_factory_.GetWeakPtr(), index)); + weak_factory_.GetWeakPtr(), + index)); } timestamp_ += buffer_duration_; } @@ -129,7 +138,7 @@ void PepperMediaStreamAudioTrackHost::AudioSink::OnSetFormat( DCHECK_LE(params.GetBufferDuration().InMilliseconds(), kMaxDuration); DCHECK_EQ(params.bits_per_sample(), 16); DCHECK_NE(GetPPSampleRate(params.sample_rate()), - PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN); + PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN); audio_params_ = params; @@ -147,9 +156,8 @@ void PepperMediaStreamAudioTrackHost::AudioSink::OnSetFormat( original_audio_params_ = params; // The size is slightly bigger than necessary, because 8 extra bytes are // added into the struct. Also see |MediaStreamBuffer|. - size_t max_data_size = - params.sample_rate() * params.bits_per_sample() / 8 * - params.channels() * kMaxDuration / 1000; + size_t max_data_size = params.sample_rate() * params.bits_per_sample() / 8 * + params.channels() * kMaxDuration / 1000; size_t size = sizeof(ppapi::MediaStreamBuffer::Audio) + max_data_size; main_message_loop_proxy_->PostTask( diff --git a/content/renderer/pepper/pepper_media_stream_track_host_base.cc b/content/renderer/pepper/pepper_media_stream_track_host_base.cc index 207de39..f21790a 100644 --- a/content/renderer/pepper/pepper_media_stream_track_host_base.cc +++ b/content/renderer/pepper/pepper_media_stream_track_host_base.cc @@ -25,11 +25,9 @@ PepperMediaStreamTrackHostBase::PepperMediaStreamTrackHostBase( PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), host_(host), - buffer_manager_(this) { -} + buffer_manager_(this) {} -PepperMediaStreamTrackHostBase::~PepperMediaStreamTrackHostBase() { -} +PepperMediaStreamTrackHostBase::~PepperMediaStreamTrackHostBase() {} bool PepperMediaStreamTrackHostBase::InitBuffers(int32_t number_of_buffers, int32_t buffer_size) { @@ -50,21 +48,22 @@ bool PepperMediaStreamTrackHostBase::InitBuffers(int32_t number_of_buffers, base::SharedMemoryHandle shm_handle = shm->handle(); if (!buffer_manager_.SetBuffers( - number_of_buffers, buffer_size, shm.Pass(), true)) { + number_of_buffers, buffer_size, shm.Pass(), true)) { return false; } base::PlatformFile platform_file = #if defined(OS_WIN) - shm_handle; + shm_handle; #elif defined(OS_POSIX) - shm_handle.fd; + shm_handle.fd; #else #error Not implemented. #endif - SerializedHandle handle( - host_->ShareHandleWithRemote(platform_file, false), size); - host()->SendUnsolicitedReplyWithHandles(pp_resource(), + SerializedHandle handle(host_->ShareHandleWithRemote(platform_file, false), + size); + host()->SendUnsolicitedReplyWithHandles( + pp_resource(), PpapiPluginMsg_MediaStreamTrack_InitBuffers(number_of_buffers, buffer_size), std::vector<SerializedHandle>(1, handle)); @@ -75,18 +74,18 @@ void PepperMediaStreamTrackHostBase::SendEnqueueBufferMessageToPlugin( int32_t index) { DCHECK_GE(index, 0); DCHECK_LT(index, buffer_manager_.number_of_buffers()); - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer(index)); + host()->SendUnsolicitedReply( + pp_resource(), PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer(index)); } int32_t PepperMediaStreamTrackHostBase::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperMediaStreamTrackHostBase, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_MediaStreamTrack_EnqueueBuffer, OnHostMsgEnqueueBuffer) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_MediaStreamTrack_Close, OnHostMsgClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_MediaStreamTrack_EnqueueBuffer, + OnHostMsgEnqueueBuffer) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_MediaStreamTrack_Close, + OnHostMsgClose) IPC_END_MESSAGE_MAP() return ppapi::host::ResourceHost::OnResourceMessageReceived(msg, context); } diff --git a/content/renderer/pepper/pepper_media_stream_track_host_base.h b/content/renderer/pepper/pepper_media_stream_track_host_base.h index 8298591..76eb41a 100644 --- a/content/renderer/pepper/pepper_media_stream_track_host_base.h +++ b/content/renderer/pepper/pepper_media_stream_track_host_base.h @@ -44,7 +44,7 @@ class PepperMediaStreamTrackHostBase // Message handlers: int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, - int32_t index); + int32_t index); int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); RendererPpapiHost* host_; diff --git a/content/renderer/pepper/pepper_media_stream_video_track_host.cc b/content/renderer/pepper/pepper_media_stream_video_track_host.cc index 776813a..12385666 100644 --- a/content/renderer/pepper/pepper_media_stream_video_track_host.cc +++ b/content/renderer/pepper/pepper_media_stream_video_track_host.cc @@ -51,8 +51,7 @@ VideoFrame::Format FromPpapiFormat(PP_VideoFrame_Format format) { // Compute size base on the size of frame received from MediaStreamVideoSink // and size specified by plugin. -gfx::Size GetTargetSize(const gfx::Size& source, - const gfx::Size& plugin) { +gfx::Size GetTargetSize(const gfx::Size& source, const gfx::Size& plugin) { return gfx::Size(plugin.width() ? plugin.width() : source.width(), plugin.height() ? plugin.height() : source.height()); } @@ -68,8 +67,7 @@ void ConvertFromMediaVideoFrame(const scoped_refptr<media::VideoFrame>& src, PP_VideoFrame_Format dst_format, const gfx::Size& dst_size, uint8_t* dst) { - CHECK(src->format() == VideoFrame::YV12 || - src->format() == VideoFrame::I420); + CHECK(src->format() == VideoFrame::YV12 || src->format() == VideoFrame::I420); if (dst_format == PP_VIDEOFRAME_FORMAT_BGRA) { if (src->coded_size() == dst_size) { libyuv::I420ToARGB(src->data(VideoFrame::kYPlane), @@ -101,8 +99,10 @@ void ConvertFromMediaVideoFrame(const scoped_refptr<media::VideoFrame>& src, } else if (dst_format == PP_VIDEOFRAME_FORMAT_YV12 || dst_format == PP_VIDEOFRAME_FORMAT_I420) { static const size_t kPlanesOrder[][3] = { - { VideoFrame::kYPlane, VideoFrame::kVPlane, VideoFrame::kUPlane }, // YV12 - { VideoFrame::kYPlane, VideoFrame::kUPlane, VideoFrame::kVPlane }, // I420 + {VideoFrame::kYPlane, VideoFrame::kVPlane, + VideoFrame::kUPlane}, // YV12 + {VideoFrame::kYPlane, VideoFrame::kUPlane, + VideoFrame::kVPlane}, // I420 }; const int plane_order = (dst_format == PP_VIDEOFRAME_FORMAT_YV12) ? 0 : 1; int dst_width = dst_size.width(); @@ -111,7 +111,10 @@ void ConvertFromMediaVideoFrame(const scoped_refptr<media::VideoFrame>& src, src->stride(kPlanesOrder[plane_order][0]), src->coded_size().width(), src->coded_size().height(), - dst, dst_width, dst_width, dst_height, + dst, + dst_width, + dst_width, + dst_height, kFilterMode); dst += dst_width * dst_height; const int src_halfwidth = (src->coded_size().width() + 1) >> 1; @@ -120,14 +123,22 @@ void ConvertFromMediaVideoFrame(const scoped_refptr<media::VideoFrame>& src, const int dst_halfheight = (dst_height + 1) >> 1; libyuv::ScalePlane(src->data(kPlanesOrder[plane_order][1]), src->stride(kPlanesOrder[plane_order][1]), - src_halfwidth, src_halfheight, - dst, dst_halfwidth, dst_halfwidth, dst_halfheight, + src_halfwidth, + src_halfheight, + dst, + dst_halfwidth, + dst_halfwidth, + dst_halfheight, kFilterMode); dst += dst_halfwidth * dst_halfheight; libyuv::ScalePlane(src->data(kPlanesOrder[plane_order][2]), src->stride(kPlanesOrder[plane_order][2]), - src_halfwidth, src_halfheight, - dst, dst_halfwidth, dst_halfwidth, dst_halfheight, + src_halfwidth, + src_halfheight, + dst, + dst_halfwidth, + dst_halfwidth, + dst_halfheight, kFilterMode); } else { NOTREACHED(); @@ -162,14 +173,14 @@ void PepperMediaStreamVideoTrackHost::InitBuffers() { DCHECK(!size.IsEmpty()); PP_VideoFrame_Format format = - GetTargetFormat(source_frame_format_, plugin_frame_format_); + GetTargetFormat(source_frame_format_, plugin_frame_format_); DCHECK_NE(format, PP_VIDEOFRAME_FORMAT_UNKNOWN); if (format == PP_VIDEOFRAME_FORMAT_BGRA) { frame_data_size_ = size.width() * size.height() * 4; } else { - frame_data_size_ = VideoFrame::AllocationSize(FromPpapiFormat(format), - size); + frame_data_size_ = + VideoFrame::AllocationSize(FromPpapiFormat(format), size); } DCHECK_GT(frame_data_size_, 0U); @@ -212,8 +223,8 @@ void PepperMediaStreamVideoTrackHost::OnVideoFrame( CHECK_EQ(ppformat, source_frame_format_) << "Frame format is changed."; gfx::Size size = GetTargetSize(source_frame_size_, plugin_frame_size_); - PP_VideoFrame_Format format = GetTargetFormat(source_frame_format_, - plugin_frame_format_); + PP_VideoFrame_Format format = + GetTargetFormat(source_frame_format_, plugin_frame_format_); ppapi::MediaStreamBuffer::Video* buffer = &(buffer_manager()->GetBufferPointer(index)->video); buffer->header.size = buffer_manager()->buffer_size(); @@ -238,9 +249,8 @@ int32_t PepperMediaStreamVideoTrackHost::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperMediaStreamVideoTrackHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_MediaStreamVideoTrack_Configure, - OnHostMsgConfigure) + PPAPI_DISPATCH_HOST_RESOURCE_CALL( + PpapiHostMsg_MediaStreamVideoTrack_Configure, OnHostMsgConfigure) IPC_END_MESSAGE_MAP() return PepperMediaStreamTrackHostBase::OnResourceMessageReceived(msg, context); @@ -255,13 +265,13 @@ int32_t PepperMediaStreamVideoTrackHost::OnHostMsgConfigure( gfx::Size new_size(attributes.width, attributes.height); if (GetTargetSize(source_frame_size_, plugin_frame_size_) != GetTargetSize(source_frame_size_, new_size)) { - changed = true; + changed = true; } plugin_frame_size_ = new_size; - int32_t buffers = attributes.buffers ? - std::min(kMaxNumberOfBuffers, attributes.buffers) : - kDefaultNumberOfBuffers; + int32_t buffers = attributes.buffers + ? std::min(kMaxNumberOfBuffers, attributes.buffers) + : kDefaultNumberOfBuffers; if (buffers != number_of_buffers_) changed = true; number_of_buffers_ = buffers; diff --git a/content/renderer/pepper/pepper_media_stream_video_track_host.h b/content/renderer/pepper/pepper_media_stream_video_track_host.h index 3b374ef..521b7ab 100644 --- a/content/renderer/pepper/pepper_media_stream_video_track_host.h +++ b/content/renderer/pepper/pepper_media_stream_video_track_host.h @@ -33,8 +33,8 @@ class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, virtual void OnClose() OVERRIDE; // MediaStreamVideoSink overrides: - virtual void OnVideoFrame( - const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; + virtual void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame) + OVERRIDE; // ResourceHost overrides: virtual void DidConnectPendingHostToResource() OVERRIDE; diff --git a/content/renderer/pepper/pepper_platform_audio_input.cc b/content/renderer/pepper/pepper_platform_audio_input.cc index 3110eaf..ed2bbcf 100644 --- a/content/renderer/pepper/pepper_platform_audio_input.cc +++ b/content/renderer/pepper/pepper_platform_audio_input.cc @@ -30,8 +30,12 @@ PepperPlatformAudioInput* PepperPlatformAudioInput::Create( PepperAudioInputHost* client) { scoped_refptr<PepperPlatformAudioInput> audio_input( new PepperPlatformAudioInput()); - if (audio_input->Initialize(render_view, device_id, document_url, - sample_rate, frames_per_buffer, client)) { + if (audio_input->Initialize(render_view, + device_id, + document_url, + sample_rate, + frames_per_buffer, + client)) { // Balanced by Release invoked in // PepperPlatformAudioInput::ShutDownOnIOThread(). audio_input->AddRef(); @@ -93,8 +97,12 @@ void PepperPlatformAudioInput::OnStreamCreated( // cleaned up on the main thread. main_message_loop_proxy_->PostTask( FROM_HERE, - base::Bind(&PepperPlatformAudioInput::OnStreamCreated, this, - handle, socket_handle, length, total_segments)); + base::Bind(&PepperPlatformAudioInput::OnStreamCreated, + this, + handle, + socket_handle, + length, + total_segments)); } else { // Must dereference the client only on the main thread. Shutdown may have // occurred while the request was in-flight, so we need to NULL check. @@ -111,12 +119,9 @@ void PepperPlatformAudioInput::OnStreamCreated( void PepperPlatformAudioInput::OnVolume(double volume) {} void PepperPlatformAudioInput::OnStateChanged( - media::AudioInputIPCDelegate::State state) { -} + media::AudioInputIPCDelegate::State state) {} -void PepperPlatformAudioInput::OnIPCClosed() { - ipc_.reset(); -} +void PepperPlatformAudioInput::OnIPCClosed() { ipc_.reset(); } PepperPlatformAudioInput::~PepperPlatformAudioInput() { // Make sure we have been shut down. Warning: this may happen on the I/O @@ -136,8 +141,7 @@ PepperPlatformAudioInput::PepperPlatformAudioInput() io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()), create_stream_sent_(false), pending_open_device_(false), - pending_open_device_id_(-1) { -} + pending_open_device_id_(-1) {} bool PepperPlatformAudioInput::Initialize( const base::WeakPtr<RenderViewImpl>& render_view, @@ -151,15 +155,19 @@ bool PepperPlatformAudioInput::Initialize( if (!render_view.get() || !client) return false; - ipc_ = RenderThreadImpl::current()->audio_input_message_filter()-> - CreateAudioInputIPC(render_view->GetRoutingID()); + ipc_ = RenderThreadImpl::current() + ->audio_input_message_filter() + ->CreateAudioInputIPC(render_view->GetRoutingID()); render_view_ = render_view; client_ = client; params_.Reset(media::AudioParameters::AUDIO_PCM_LINEAR, - media::CHANNEL_LAYOUT_MONO, ppapi::kAudioInputChannels, 0, - sample_rate, ppapi::kBitsPerAudioInputSample, + media::CHANNEL_LAYOUT_MONO, + ppapi::kAudioInputChannels, + 0, + sample_rate, + ppapi::kBitsPerAudioInputSample, frames_per_buffer); // We need to open the device and obtain the label and session ID before @@ -208,8 +216,7 @@ void PepperPlatformAudioInput::ShutDownOnIOThread() { StopCaptureOnIOThread(); main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PepperPlatformAudioInput::CloseDevice, this)); + FROM_HERE, base::Bind(&PepperPlatformAudioInput::CloseDevice, this)); Release(); // Release for the delegate, balances out the reference taken in // PepperPlatformAudioInput::Create. @@ -233,7 +240,8 @@ void PepperPlatformAudioInput::OnDeviceOpened(int request_id, io_message_loop_proxy_->PostTask( FROM_HERE, base::Bind(&PepperPlatformAudioInput::InitializeOnIOThread, - this, session_id)); + this, + session_id)); } else { // Shutdown has occurred. CloseDevice(); diff --git a/content/renderer/pepper/pepper_platform_audio_input.h b/content/renderer/pepper/pepper_platform_audio_input.h index 47b9ebb..56a701a 100644 --- a/content/renderer/pepper/pepper_platform_audio_input.h +++ b/content/renderer/pepper/pepper_platform_audio_input.h @@ -64,8 +64,8 @@ class PepperPlatformAudioInput int length, int total_segments) OVERRIDE; virtual void OnVolume(double volume) OVERRIDE; - virtual void OnStateChanged( - media::AudioInputIPCDelegate::State state) OVERRIDE; + virtual void OnStateChanged(media::AudioInputIPCDelegate::State state) + OVERRIDE; virtual void OnIPCClosed() OVERRIDE; protected: @@ -76,13 +76,12 @@ class PepperPlatformAudioInput PepperPlatformAudioInput(); - bool Initialize( - const base::WeakPtr<RenderViewImpl>& render_view, - const std::string& device_id, - const GURL& document_url, - int sample_rate, - int frames_per_buffer, - PepperAudioInputHost* client); + bool Initialize(const base::WeakPtr<RenderViewImpl>& render_view, + const std::string& device_id, + const GURL& document_url, + int sample_rate, + int frames_per_buffer, + PepperAudioInputHost* client); // I/O thread backends to above functions. void InitializeOnIOThread(int session_id); @@ -90,9 +89,7 @@ class PepperPlatformAudioInput void StopCaptureOnIOThread(); void ShutDownOnIOThread(); - void OnDeviceOpened(int request_id, - bool succeeded, - const std::string& label); + void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); void CloseDevice(); void NotifyStreamCreationFailed(); diff --git a/content/renderer/pepper/pepper_platform_audio_output.cc b/content/renderer/pepper/pepper_platform_audio_output.cc index 94cdd8d..7d65685 100644 --- a/content/renderer/pepper/pepper_platform_audio_output.cc +++ b/content/renderer/pepper/pepper_platform_audio_output.cc @@ -27,8 +27,10 @@ PepperPlatformAudioOutput* PepperPlatformAudioOutput::Create( AudioHelper* client) { scoped_refptr<PepperPlatformAudioOutput> audio_output( new PepperPlatformAudioOutput()); - if (audio_output->Initialize(sample_rate, frames_per_buffer, - source_render_view_id, source_render_frame_id, + if (audio_output->Initialize(sample_rate, + frames_per_buffer, + source_render_view_id, + source_render_frame_id, client)) { // Balanced by Release invoked in // PepperPlatformAudioOutput::ShutDownOnIOThread(). @@ -68,8 +70,7 @@ void PepperPlatformAudioOutput::ShutDown() { } void PepperPlatformAudioOutput::OnStateChanged( - media::AudioOutputIPCDelegate::State state) { -} + media::AudioOutputIPCDelegate::State state) {} void PepperPlatformAudioOutput::OnStreamCreated( base::SharedMemoryHandle handle, @@ -85,21 +86,23 @@ void PepperPlatformAudioOutput::OnStreamCreated( DCHECK(length); if (base::MessageLoopProxy::current().get() == - main_message_loop_proxy_.get()) { + main_message_loop_proxy_.get()) { // Must dereference the client only on the main thread. Shutdown may have // occurred while the request was in-flight, so we need to NULL check. if (client_) client_->StreamCreated(handle, length, socket_handle); } else { - main_message_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this, handle, - socket_handle, length)); + main_message_loop_proxy_->PostTask( + FROM_HERE, + base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, + this, + handle, + socket_handle, + length)); } } -void PepperPlatformAudioOutput::OnIPCClosed() { - ipc_.reset(); -} +void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); } PepperPlatformAudioOutput::~PepperPlatformAudioOutput() { // Make sure we have been shut down. Warning: this will usually happen on @@ -114,29 +117,29 @@ PepperPlatformAudioOutput::PepperPlatformAudioOutput() io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()) { } -bool PepperPlatformAudioOutput::Initialize( - int sample_rate, - int frames_per_buffer, - int source_render_view_id, - int source_render_frame_id, - AudioHelper* client) { +bool PepperPlatformAudioOutput::Initialize(int sample_rate, + int frames_per_buffer, + int source_render_view_id, + int source_render_frame_id, + AudioHelper* client) { DCHECK(client); client_ = client; RenderThreadImpl* const render_thread = RenderThreadImpl::current(); - ipc_ = render_thread->audio_message_filter()-> - CreateAudioOutputIPC(source_render_view_id, source_render_frame_id); + ipc_ = render_thread->audio_message_filter()->CreateAudioOutputIPC( + source_render_view_id, source_render_frame_id); CHECK(ipc_); - media::AudioParameters params( - media::AudioParameters::AUDIO_PCM_LOW_LATENCY, - media::CHANNEL_LAYOUT_STEREO, sample_rate, - ppapi::kBitsPerAudioOutputSample, frames_per_buffer); + media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, + media::CHANNEL_LAYOUT_STEREO, + sample_rate, + ppapi::kBitsPerAudioOutputSample, + frames_per_buffer); io_message_loop_proxy_->PostTask( FROM_HERE, - base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, this, - params)); + base::Bind( + &PepperPlatformAudioOutput::InitializeOnIOThread, this, params)); return true; } diff --git a/content/renderer/pepper/pepper_platform_audio_output.h b/content/renderer/pepper/pepper_platform_audio_output.h index affe7bb..725d42f 100644 --- a/content/renderer/pepper/pepper_platform_audio_output.h +++ b/content/renderer/pepper/pepper_platform_audio_output.h @@ -48,8 +48,8 @@ class PepperPlatformAudioOutput void ShutDown(); // media::AudioOutputIPCDelegate implementation. - virtual void OnStateChanged( - media::AudioOutputIPCDelegate::State state) OVERRIDE; + virtual void OnStateChanged(media::AudioOutputIPCDelegate::State state) + OVERRIDE; virtual void OnStreamCreated(base::SharedMemoryHandle handle, base::SyncSocket::Handle socket_handle, int length) OVERRIDE; diff --git a/content/renderer/pepper/pepper_platform_context_3d.cc b/content/renderer/pepper/pepper_platform_context_3d.cc index 3d46f33..239c67d 100644 --- a/content/renderer/pepper/pepper_platform_context_3d.cc +++ b/content/renderer/pepper/pepper_platform_context_3d.cc @@ -18,10 +18,7 @@ namespace content { PlatformContext3D::PlatformContext3D() - : has_alpha_(false), - command_buffer_(NULL), - weak_ptr_factory_(this) { -} + : has_alpha_(false), command_buffer_(NULL), weak_ptr_factory_(this) {} PlatformContext3D::~PlatformContext3D() { if (command_buffer_) { @@ -56,8 +53,7 @@ bool PlatformContext3D::Init(const int32* attrib_list, // interface to accept width and height in the attrib_list so that // we do not need to filter for width and height here. if (attrib_list) { - for (const int32_t* attr = attrib_list; - attr[0] != PP_GRAPHICS3DATTRIB_NONE; + for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; attr += 2) { switch (attr[0]) { case PP_GRAPHICS3DATTRIB_WIDTH: @@ -68,8 +64,9 @@ bool PlatformContext3D::Init(const int32* attrib_list, break; case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: gpu_preference = - (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) ? - gfx::PreferIntegratedGpu : gfx::PreferDiscreteGpu; + (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) + ? gfx::PreferIntegratedGpu + : gfx::PreferDiscreteGpu; break; case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: has_alpha_ = attr[1] > 0; @@ -91,11 +88,7 @@ bool PlatformContext3D::Init(const int32* attrib_list, } command_buffer_ = channel_->CreateOffscreenCommandBuffer( - surface_size, - share_buffer, - attribs, - GURL::EmptyGURL(), - gpu_preference); + surface_size, share_buffer, attribs, GURL::EmptyGURL(), gpu_preference); if (!command_buffer_) return false; if (!command_buffer_->Initialize()) @@ -106,12 +99,10 @@ bool PlatformContext3D::Init(const int32* attrib_list, mailbox_ = mailbox; sync_point_ = command_buffer_->InsertSyncPoint(); - command_buffer_->SetChannelErrorCallback( - base::Bind(&PlatformContext3D::OnContextLost, - weak_ptr_factory_.GetWeakPtr())); - command_buffer_->SetOnConsoleMessageCallback( - base::Bind(&PlatformContext3D::OnConsoleMessage, - weak_ptr_factory_.GetWeakPtr())); + command_buffer_->SetChannelErrorCallback(base::Bind( + &PlatformContext3D::OnContextLost, weak_ptr_factory_.GetWeakPtr())); + command_buffer_->SetOnConsoleMessageCallback(base::Bind( + &PlatformContext3D::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); return true; } @@ -136,9 +127,7 @@ gpu::CommandBuffer* PlatformContext3D::GetCommandBuffer() { return command_buffer_; } -gpu::GpuControl* PlatformContext3D::GetGpuControl() { - return command_buffer_; -} +gpu::GpuControl* PlatformContext3D::GetGpuControl() { return command_buffer_; } int PlatformContext3D::GetCommandBufferRouteId() { DCHECK(command_buffer_); diff --git a/content/renderer/pepper/pepper_platform_context_3d.h b/content/renderer/pepper/pepper_platform_context_3d.h index dcd42ca..8112ea9 100644 --- a/content/renderer/pepper/pepper_platform_context_3d.h +++ b/content/renderer/pepper/pepper_platform_context_3d.h @@ -54,8 +54,7 @@ class PlatformContext3D { // Set an optional callback that will be invoked when the context is lost // (e.g. gpu process crash). Takes ownership of the callback. - typedef base::Callback<void(const std::string&, int)> - ConsoleMessageCallback; + typedef base::Callback<void(const std::string&, int)> ConsoleMessageCallback; void SetContextLostCallback(const base::Closure& callback); // Set an optional callback that will be invoked when the GPU process diff --git a/content/renderer/pepper/pepper_platform_video_capture.cc b/content/renderer/pepper/pepper_platform_video_capture.cc index 7a7809b..60fc32e 100644 --- a/content/renderer/pepper/pepper_platform_video_capture.cc +++ b/content/renderer/pepper/pepper_platform_video_capture.cc @@ -26,7 +26,8 @@ PepperPlatformVideoCapture::PepperPlatformVideoCapture( device_id_(device_id), session_id_(0), handler_proxy_(new media::VideoCaptureHandlerProxy( - this, base::MessageLoopProxy::current())), + this, + base::MessageLoopProxy::current())), handler_(handler), unbalanced_start_(false), pending_open_device_(false), @@ -172,8 +173,7 @@ void PepperPlatformVideoCapture::OnDeviceOpened(int request_id, handler_->OnInitialized(this, succeeded); } -PepperMediaDeviceManager* - PepperPlatformVideoCapture::GetMediaDeviceManager() { +PepperMediaDeviceManager* PepperPlatformVideoCapture::GetMediaDeviceManager() { return PepperMediaDeviceManager::GetForRenderView(render_view_.get()); } diff --git a/content/renderer/pepper/pepper_platform_video_capture.h b/content/renderer/pepper/pepper_platform_video_capture.h index 5c1597c..1d0b47c 100644 --- a/content/renderer/pepper/pepper_platform_video_capture.h +++ b/content/renderer/pepper/pepper_platform_video_capture.h @@ -31,26 +31,24 @@ class PepperPlatformVideoCapture public base::RefCounted<PepperPlatformVideoCapture>, public media::VideoCapture::EventHandler { public: - PepperPlatformVideoCapture( - const base::WeakPtr<RenderViewImpl>& render_view, - const std::string& device_id, - const GURL& document_url, - PepperVideoCaptureHost* handler); + PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, + const std::string& device_id, + const GURL& document_url, + PepperVideoCaptureHost* handler); // Detaches the event handler and stops sending notifications to it. void DetachEventHandler(); // media::VideoCapture implementation. - virtual void StartCapture( - media::VideoCapture::EventHandler* handler, - const media::VideoCaptureParams& params) OVERRIDE; + virtual void StartCapture(media::VideoCapture::EventHandler* handler, + const media::VideoCaptureParams& params) OVERRIDE; virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; virtual bool CaptureStarted() OVERRIDE; virtual int CaptureFrameRate() OVERRIDE; - virtual void GetDeviceSupportedFormats( - const DeviceFormatsCallback& callback) OVERRIDE; - virtual void GetDeviceFormatsInUse( - const DeviceFormatsInUseCallback& callback) OVERRIDE; + virtual void GetDeviceSupportedFormats(const DeviceFormatsCallback& callback) + OVERRIDE; + virtual void GetDeviceFormatsInUse(const DeviceFormatsInUseCallback& callback) + OVERRIDE; // media::VideoCapture::EventHandler implementation virtual void OnStarted(VideoCapture* capture) OVERRIDE; @@ -58,9 +56,9 @@ class PepperPlatformVideoCapture virtual void OnPaused(VideoCapture* capture) OVERRIDE; virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE; virtual void OnRemoved(VideoCapture* capture) OVERRIDE; - virtual void OnFrameReady( - VideoCapture* capture, - const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; + virtual void OnFrameReady(VideoCapture* capture, + const scoped_refptr<media::VideoFrame>& frame) + OVERRIDE; protected: friend class base::RefCounted<PepperPlatformVideoCapture>; @@ -69,9 +67,7 @@ class PepperPlatformVideoCapture private: void Initialize(); - void OnDeviceOpened(int request_id, - bool succeeded, - const std::string& label); + void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); PepperMediaDeviceManager* GetMediaDeviceManager(); diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 5cce7ea..3b944f8 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -183,12 +183,21 @@ namespace content { #if defined(OS_WIN) // Exported by pdf.dll -typedef bool (*RenderPDFPageToDCProc)( - const unsigned char* pdf_buffer, int buffer_size, int page_number, HDC dc, - int dpi_x, int dpi_y, int bounds_origin_x, int bounds_origin_y, - int bounds_width, int bounds_height, bool fit_to_bounds, - bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds, - bool autorotate); +typedef bool (*RenderPDFPageToDCProc)(const unsigned char* pdf_buffer, + int buffer_size, + int page_number, + HDC dc, + int dpi_x, + int dpi_y, + int bounds_origin_x, + int bounds_origin_y, + int bounds_width, + int bounds_height, + bool fit_to_bounds, + bool stretch_to_bounds, + bool keep_aspect_ratio, + bool center_in_bounds, + bool autorotate); void DrawEmptyRectangle(HDC dc) { // TODO(sanjeevr): This is a temporary hack. If we output a JPEG @@ -204,22 +213,24 @@ void DrawEmptyRectangle(HDC dc) { namespace { // Check PP_TextInput_Type and ui::TextInputType are kept in sync. -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == \ - int(PP_TEXTINPUT_TYPE_NONE), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == \ - int(PP_TEXTINPUT_TYPE_TEXT), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == \ - int(PP_TEXTINPUT_TYPE_PASSWORD), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == \ - int(PP_TEXTINPUT_TYPE_SEARCH), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == \ - int(PP_TEXTINPUT_TYPE_EMAIL), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == \ - int(PP_TEXTINPUT_TYPE_NUMBER), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == \ - int(PP_TEXTINPUT_TYPE_TELEPHONE), mismatching_enums); -COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == \ - int(PP_TEXTINPUT_TYPE_URL), mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == int(PP_TEXTINPUT_TYPE_NONE), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == + int(PP_TEXTINPUT_TYPE_PASSWORD), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == + int(PP_TEXTINPUT_TYPE_TELEPHONE), + mismatching_enums); +COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == int(PP_TEXTINPUT_TYPE_URL), + mismatching_enums); // The default text input type is to regard the plugin always accept text input. // This is for allowing users to use input methods even on completely-IME- @@ -228,15 +239,14 @@ COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == \ // that they don't accept texts. const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; -#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ - COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ - == static_cast<int>(np_name), \ - mismatching_enums) +#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ + COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) == \ + static_cast<int>(np_name), \ + mismatching_enums) -#define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ - COMPILE_ASSERT(static_cast<int>(webkit_name) \ - == static_cast<int>(pp_name), \ - mismatching_enums) +#define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ + COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(pp_name), \ + mismatching_enums) // <embed>/<object> attributes. const char kWidth[] = "width"; @@ -313,7 +323,8 @@ COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( blink::WebPrintScalingOptionFitToPrintableArea, PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( - blink::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); + blink::WebPrintScalingOptionSourceSize, + PP_PRINTSCALINGOPTION_SOURCE_SIZE); // Sets |*security_origin| to be the WebKit security origin associated with the // document containing the given plugin instance. On success, returns true. If @@ -334,9 +345,9 @@ bool SecurityOriginForInstance(PP_Instance instance_id, // Convert the given vector to an array of C-strings. The strings in the // returned vector are only guaranteed valid so long as the vector of strings // is not modified. -scoped_ptr<const char*[]> StringVectorToArgArray( +scoped_ptr<const char* []> StringVectorToArgArray( const std::vector<std::string>& vector) { - scoped_ptr<const char*[]> array(new const char*[vector.size()]); + scoped_ptr<const char * []> array(new const char* [vector.size()]); for (size_t i = 0; i < vector.size(); ++i) array[i] = vector[i].c_str(); return array.Pass(); @@ -378,12 +389,10 @@ class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { plugin_->OnLockMouseACK(succeeded); } - virtual void OnMouseLockLost() OVERRIDE { - plugin_->OnMouseLockLost(); - } + virtual void OnMouseLockLost() OVERRIDE { plugin_->OnMouseLockLost(); } - virtual bool HandleMouseLockedInputEvent( - const blink::WebMouseEvent &event) OVERRIDE { + virtual bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) + OVERRIDE { plugin_->HandleMouseLockedInputEvent(event); return true; } @@ -392,7 +401,6 @@ class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { PepperPluginInstanceImpl* plugin_; }; - } // namespace // static @@ -407,27 +415,26 @@ PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( PPP_Instance_Combined::Create(get_plugin_interface_func); if (!ppp_instance_combined) return NULL; - return new PepperPluginInstanceImpl(render_frame, module, - ppp_instance_combined, container, - plugin_url); + return new PepperPluginInstanceImpl( + render_frame, module, ppp_instance_combined, container, plugin_url); } PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() - : finished_loading_(false) { -} + : finished_loading_(false) {} -PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() { -} +PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( WebURLLoaderClient* document_loader) { - for (std::list<std::string>::iterator it = data_.begin(); - it != data_.end(); ++it) { - document_loader->didReceiveData(NULL, it->c_str(), it->length(), - 0 /* encoded_data_length */); + for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); + ++it) { + document_loader->didReceiveData( + NULL, it->c_str(), it->length(), 0 /* encoded_data_length */); } if (finished_loading_) { - document_loader->didFinishLoading(NULL, 0 /* finish_time */, + document_loader->didFinishLoading( + NULL, + 0 /* finish_time */, blink::WebURLLoaderClient::kUnknownEncodedDataLength); } if (error_.get()) { @@ -459,11 +466,9 @@ void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( } PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() - : Resource(ppapi::Resource::Untracked()) { -} + : Resource(ppapi::Resource::Untracked()) {} -PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { -} +PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() {} PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { return this; @@ -474,8 +479,7 @@ void PepperPluginInstanceImpl::GamepadImpl::Sample( PP_GamepadsSampleData* data) { blink::WebGamepads webkit_data; RenderThreadImpl::current()->SampleGamepads(&webkit_data); - ConvertWebKitGamepadData( - bit_cast<ppapi::WebKitGamepads>(webkit_data), data); + ConvertWebKitGamepadData(bit_cast<ppapi::WebKitGamepads>(webkit_data), data); } PepperPluginInstanceImpl::PepperPluginInstanceImpl( @@ -597,7 +601,8 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { PluginObjectSet plugin_object_copy; live_plugin_objects_.swap(plugin_object_copy); for (PluginObjectSet::iterator i = plugin_object_copy.begin(); - i != plugin_object_copy.end(); ++i) + i != plugin_object_copy.end(); + ++i) delete *i; if (TrackedCallback::IsPending(lock_mouse_callback_)) @@ -667,9 +672,7 @@ void PepperPluginInstanceImpl::Delete() { container_ = NULL; } -bool PepperPluginInstanceImpl::is_deleted() const { - return is_deleted_; -} +bool PepperPluginInstanceImpl::is_deleted() const { return is_deleted_; } void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, const gfx::Rect& plugin_rect, @@ -695,8 +698,8 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { else fullscreen_container_->InvalidateRect(rect); } else { - if (!container_ || - view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) + if (!container_ || view_data_.rect.size.width == 0 || + view_data_.rect.size.height == 0) return; // Nothing to do. if (rect.IsEmpty()) container_->invalidate(); @@ -769,8 +772,8 @@ void PepperPluginInstanceImpl::InstanceCrashed() { static void SetGPUHistogram(const ppapi::Preferences& prefs, const std::vector<std::string>& arg_names, const std::vector<std::string>& arg_values) { - // Calculate a histogram to let us determine how likely people are to try to - // run Stage3D content on machines that have it blacklisted. +// Calculate a histogram to let us determine how likely people are to try to +// run Stage3D content on machines that have it blacklisted. #if defined(OS_WIN) bool needs_gpu = false; bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP; @@ -792,8 +795,8 @@ static void SetGPUHistogram(const ppapi::Preferences& prefs, // 5 : No 3D content and GPU is not blacklisted on XP // 6 : 3D content but GPU is blacklisted on XP // 7 : 3D content and GPU is not blacklisted on XP - UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", - is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); + UMA_HISTOGRAM_ENUMERATION( + "Flash.UsesGPU", is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); #endif } @@ -810,18 +813,17 @@ bool PepperPluginInstanceImpl::Initialize( UpdateTouchEventRequest(); container_->setWantsWheelEvents(IsAcceptingWheelEvents()); - SetGPUHistogram(ppapi::Preferences( - render_frame_->render_view()->webkit_preferences()), - arg_names, arg_values); + SetGPUHistogram( + ppapi::Preferences(render_frame_->render_view()->webkit_preferences()), + arg_names, + arg_values); argn_ = arg_names; argv_ = arg_values; - scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); - scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); - bool success = PP_ToBool(instance_interface_->DidCreate(pp_instance(), - argn_.size(), - argn_array.get(), - argv_array.get())); + scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); + scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); + bool success = PP_ToBool(instance_interface_->DidCreate( + pp_instance(), argn_.size(), argn_array.get(), argv_array.get())); if (success) message_channel_->StopQueueingJavaScriptMessages(); return success; @@ -883,20 +885,24 @@ bool PepperPluginInstanceImpl::HandleDocumentLoad( } bool PepperPluginInstanceImpl::SendCompositionEventToPlugin( - PP_InputEvent_Type type, const base::string16& text) { + PP_InputEvent_Type type, + const base::string16& text) { std::vector<blink::WebCompositionUnderline> empty; return SendCompositionEventWithUnderlineInformationToPlugin( - type, text, empty, static_cast<int>(text.size()), + type, + text, + empty, + static_cast<int>(text.size()), static_cast<int>(text.size())); } -bool PepperPluginInstanceImpl:: - SendCompositionEventWithUnderlineInformationToPlugin( - PP_InputEvent_Type type, - const base::string16& text, - const std::vector<blink::WebCompositionUnderline>& underlines, - int selection_start, - int selection_end) { +bool +PepperPluginInstanceImpl::SendCompositionEventWithUnderlineInformationToPlugin( + PP_InputEvent_Type type, + const base::string16& text, + const std::vector<blink::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end) { // Keep a reference on the stack. See NOTE above. scoped_refptr<PepperPluginInstanceImpl> ref(this); @@ -910,8 +916,8 @@ bool PepperPluginInstanceImpl:: ppapi::InputEventData event; event.event_type = type; - event.event_time_stamp = ppapi::TimeTicksToPPTimeTicks( - base::TimeTicks::Now()); + event.event_time_stamp = + ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); // Convert UTF16 text to UTF8 with offset conversion. std::vector<size_t> utf16_offsets; @@ -925,14 +931,16 @@ bool PepperPluginInstanceImpl:: event.character_text = base::UTF16ToUTF8AndAdjustOffsets(text, &utf8_offsets); // Set the converted selection range. - event.composition_selection_start = (utf8_offsets[0] == std::string::npos ? - event.character_text.size() : utf8_offsets[0]); - event.composition_selection_end = (utf8_offsets[1] == std::string::npos ? - event.character_text.size() : utf8_offsets[1]); + event.composition_selection_start = + (utf8_offsets[0] == std::string::npos ? event.character_text.size() + : utf8_offsets[0]); + event.composition_selection_end = + (utf8_offsets[1] == std::string::npos ? event.character_text.size() + : utf8_offsets[1]); // Set the converted segmentation points. // Be sure to add 0 and size(), and remove duplication or errors. - std::set<size_t> offset_set(utf8_offsets.begin()+2, utf8_offsets.end()); + std::set<size_t> offset_set(utf8_offsets.begin() + 2, utf8_offsets.end()); offset_set.insert(0); offset_set.insert(event.character_text.size()); offset_set.erase(std::string::npos); @@ -945,7 +953,7 @@ bool PepperPluginInstanceImpl:: std::vector<uint32_t>::iterator it = std::find(event.composition_segment_offsets.begin(), event.composition_segment_offsets.end(), - utf8_offsets[2*i+2]); + utf8_offsets[2 * i + 2]); if (it != event.composition_segment_offsets.end()) { event.composition_target_segment = it - event.composition_segment_offsets.begin(); @@ -988,7 +996,10 @@ bool PepperPluginInstanceImpl::HandleCompositionUpdate( int selection_end) { return SendCompositionEventWithUnderlineInformationToPlugin( PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, - text, underlines, selection_start, selection_end); + text, + underlines, + selection_start, + selection_end); } bool PepperPluginInstanceImpl::HandleCompositionEnd( @@ -998,8 +1009,7 @@ bool PepperPluginInstanceImpl::HandleCompositionEnd( } bool PepperPluginInstanceImpl::HandleTextInput(const base::string16& text) { - return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, - text); + return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, text); } void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text, @@ -1016,7 +1026,7 @@ void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text, bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || - (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); + (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); } gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { @@ -1024,7 +1034,8 @@ gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { // If it is never set by the plugin, use the bottom left corner. return gfx::Rect(view_data_.rect.point.x, view_data_.rect.point.y + view_data_.rect.size.height, - 0, 0); + 0, + 0); } // TODO(kinaba) Take CSS transformation into accont. @@ -1068,7 +1079,7 @@ bool PepperPluginInstanceImpl::HandleInputEvent( if ((filtered_input_event_mask_ & event_class) || (input_event_mask_ & event_class)) { // Actually send the event. - std::vector< ppapi::InputEventData > events; + std::vector<ppapi::InputEventData> events; CreateInputEventData(event, &events); // Allow the user gesture to be pending after the plugin handles the @@ -1089,8 +1100,8 @@ bool PepperPluginInstanceImpl::HandleInputEvent( else rv = true; // Unfiltered events are assumed to be handled. scoped_refptr<PPB_InputEvent_Shared> event_resource( - new PPB_InputEvent_Shared(ppapi::OBJECT_IS_IMPL, - pp_instance(), events[i])); + new PPB_InputEvent_Shared( + ppapi::OBJECT_IS_IMPL, pp_instance(), events[i])); rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( pp_instance(), event_resource->pp_resource())); @@ -1140,8 +1151,8 @@ void PepperPluginInstanceImpl::ViewChanged( view_data_.rect = PP_FromGfxRect(position); view_data_.clip_rect = PP_FromGfxRect(clip); view_data_.device_scale = container_->deviceScaleFactor(); - view_data_.css_scale = container_->pageZoomFactor() * - container_->pageScaleFactor(); + view_data_.css_scale = + container_->pageZoomFactor() * container_->pageScaleFactor(); if (desired_fullscreen_state_ || view_data_.is_fullscreen) { WebElement element = container_->element(); @@ -1308,10 +1319,9 @@ bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, return false; find_identifier_ = identifier; return PP_ToBool( - plugin_find_interface_->StartFind( - pp_instance(), - base::UTF16ToUTF8(search_text).c_str(), - PP_FromBool(case_sensitive))); + plugin_find_interface_->StartFind(pp_instance(), + base::UTF16ToUTF8(search_text).c_str(), + PP_FromBool(case_sensitive))); } void PepperPluginInstanceImpl::SelectFindResult(bool forward) { @@ -1335,9 +1345,8 @@ bool PepperPluginInstanceImpl::LoadFindInterface() { if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) return false; if (!plugin_find_interface_) { - plugin_find_interface_ = - static_cast<const PPP_Find_Private*>(module_->GetPluginInterface( - PPP_FIND_PRIVATE_INTERFACE)); + plugin_find_interface_ = static_cast<const PPP_Find_Private*>( + module_->GetPluginInterface(PPP_FIND_PRIVATE_INTERFACE)); } return !!plugin_find_interface_; @@ -1346,9 +1355,8 @@ bool PepperPluginInstanceImpl::LoadFindInterface() { bool PepperPluginInstanceImpl::LoadInputEventInterface() { if (!checked_for_plugin_input_event_interface_) { checked_for_plugin_input_event_interface_ = true; - plugin_input_event_interface_ = - static_cast<const PPP_InputEvent*>(module_->GetPluginInterface( - PPP_INPUT_EVENT_INTERFACE)); + plugin_input_event_interface_ = static_cast<const PPP_InputEvent*>( + module_->GetPluginInterface(PPP_INPUT_EVENT_INTERFACE)); } return !!plugin_input_event_interface_; } @@ -1356,18 +1364,16 @@ bool PepperPluginInstanceImpl::LoadInputEventInterface() { bool PepperPluginInstanceImpl::LoadMessagingInterface() { if (!checked_for_plugin_messaging_interface_) { checked_for_plugin_messaging_interface_ = true; - plugin_messaging_interface_ = - static_cast<const PPP_Messaging*>(module_->GetPluginInterface( - PPP_MESSAGING_INTERFACE)); + plugin_messaging_interface_ = static_cast<const PPP_Messaging*>( + module_->GetPluginInterface(PPP_MESSAGING_INTERFACE)); } return !!plugin_messaging_interface_; } bool PepperPluginInstanceImpl::LoadMouseLockInterface() { if (!plugin_mouse_lock_interface_) { - plugin_mouse_lock_interface_ = - static_cast<const PPP_MouseLock*>(module_->GetPluginInterface( - PPP_MOUSELOCK_INTERFACE)); + plugin_mouse_lock_interface_ = static_cast<const PPP_MouseLock*>( + module_->GetPluginInterface(PPP_MOUSELOCK_INTERFACE)); } return !!plugin_mouse_lock_interface_; @@ -1376,9 +1382,8 @@ bool PepperPluginInstanceImpl::LoadMouseLockInterface() { bool PepperPluginInstanceImpl::LoadPdfInterface() { if (!checked_for_plugin_pdf_interface_) { checked_for_plugin_pdf_interface_ = true; - plugin_pdf_interface_ = - static_cast<const PPP_Pdf_1*>(module_->GetPluginInterface( - PPP_PDF_INTERFACE_1)); + plugin_pdf_interface_ = static_cast<const PPP_Pdf_1*>( + module_->GetPluginInterface(PPP_PDF_INTERFACE_1)); } return !!plugin_pdf_interface_; @@ -1404,8 +1409,8 @@ bool PepperPluginInstanceImpl::LoadPrivateInterface() { // // If this is *not* a NaCl plugin, original_module_ will never be set; we talk // to the "real" module. - scoped_refptr<PluginModule> module = original_module_ ? original_module_ : - module_; + scoped_refptr<PluginModule> module = + original_module_ ? original_module_ : module_; // Only check for the interface if the plugin has private permission. if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) return false; @@ -1419,18 +1424,16 @@ bool PepperPluginInstanceImpl::LoadPrivateInterface() { bool PepperPluginInstanceImpl::LoadSelectionInterface() { if (!plugin_selection_interface_) { - plugin_selection_interface_ = - static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( - PPP_SELECTION_DEV_INTERFACE)); + plugin_selection_interface_ = static_cast<const PPP_Selection_Dev*>( + module_->GetPluginInterface(PPP_SELECTION_DEV_INTERFACE)); } return !!plugin_selection_interface_; } bool PepperPluginInstanceImpl::LoadTextInputInterface() { if (!plugin_textinput_interface_) { - plugin_textinput_interface_ = - static_cast<const PPP_TextInput_Dev*>(module_->GetPluginInterface( - PPP_TEXTINPUT_DEV_INTERFACE)); + plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( + module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); } return !!plugin_textinput_interface_; @@ -1438,9 +1441,8 @@ bool PepperPluginInstanceImpl::LoadTextInputInterface() { bool PepperPluginInstanceImpl::LoadZoomInterface() { if (!plugin_zoom_interface_) { - plugin_zoom_interface_ = - static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( - PPP_ZOOM_DEV_INTERFACE)); + plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>( + module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE)); } return !!plugin_zoom_interface_; @@ -1498,14 +1500,15 @@ void PepperPluginInstanceImpl::SendFocusChangeNotification() { void PepperPluginInstanceImpl::UpdateTouchEventRequest() { bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); - container_->requestTouchEventType(raw_touch ? - blink::WebPluginContainer::TouchEventRequestTypeRaw : - blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); + container_->requestTouchEventType( + raw_touch + ? blink::WebPluginContainer::TouchEventRequestTypeRaw + : blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); } bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || - (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); + (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); } void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { @@ -1541,17 +1544,16 @@ void PepperPluginInstanceImpl::SendDidChangeView() { last_sent_view_data_ = view_data_; ScopedPPResource resource( ScopedPPResource::PassRef(), - (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, - pp_instance(), view_data_))->GetReference()); + (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, pp_instance(), view_data_)) + ->GetReference()); UpdateLayerTransform(); // It's possible that Delete() has been called but the renderer hasn't // released its reference to this object yet. if (instance_interface_) { - instance_interface_->DidChangeView(pp_instance(), resource, - &view_data_.rect, - &view_data_.clip_rect); + instance_interface_->DidChangeView( + pp_instance(), resource, &view_data_.rect, &view_data_.clip_rect); } } @@ -1608,11 +1610,10 @@ int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { print_settings.dpi = print_params.printerDPI; print_settings.orientation = PP_PRINTORIENTATION_NORMAL; print_settings.grayscale = PP_FALSE; - print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( - print_params.printScalingOption); + print_settings.print_scaling_option = + static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption); print_settings.format = format; - num_pages = plugin_print_interface_->Begin(pp_instance(), - &print_settings); + num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); if (!num_pages) return 0; current_print_settings_ = print_settings; @@ -1699,9 +1700,9 @@ void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) { if (!LoadPdfInterface()) return; PP_PrivatePageTransformType transform_type = - type == WebPlugin::RotationType90Clockwise ? - PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : - PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; + type == WebPlugin::RotationType90Clockwise + ? PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW + : PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; plugin_pdf_interface_->Transform(pp_instance(), transform_type); // NOTE: plugin instance may have been deleted. } @@ -1726,9 +1727,9 @@ bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) { if (!render_frame_) return false; - if (fullscreen && - !render_frame_->render_view()->renderer_preferences(). - plugin_fullscreen_allowed) + if (fullscreen && !render_frame_->render_view() + ->renderer_preferences() + .plugin_fullscreen_allowed) return false; // Check whether we are trying to switch while the state is in transition. @@ -1822,9 +1823,8 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, HMODULE pdf_module = GetModuleHandle(L"pdf.dll"); if (!pdf_module) return false; - RenderPDFPageToDCProc render_proc = - reinterpret_cast<RenderPDFPageToDCProc>( - GetProcAddress(pdf_module, "RenderPDFPageToDC")); + RenderPDFPageToDCProc render_proc = reinterpret_cast<RenderPDFPageToDCProc>( + GetProcAddress(pdf_module, "RenderPDFPageToDC")); if (!render_proc) return false; #endif // defined(OS_WIN) @@ -1841,7 +1841,7 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, ret = metafile->InitFromData(mapper.data(), mapper.size()); #elif defined(OS_WIN) printing::Metafile* metafile = - printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); + printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); if (metafile) { // We only have a metafile when doing print preview, so we just want to // pass the PDF off to preview. @@ -1852,10 +1852,10 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, HDC dc = skia::BeginPlatformPaint(canvas); DrawEmptyRectangle(dc); gfx::Size size_in_pixels; - size_in_pixels.set_width(printing::ConvertUnit( - current_print_settings_.printable_area.size.width, - static_cast<int>(printing::kPointsPerInch), - current_print_settings_.dpi)); + size_in_pixels.set_width( + printing::ConvertUnit(current_print_settings_.printable_area.size.width, + static_cast<int>(printing::kPointsPerInch), + current_print_settings_.dpi)); size_in_pixels.set_height(printing::ConvertUnit( current_print_settings_.printable_area.size.height, static_cast<int>(printing::kPointsPerInch), @@ -1870,10 +1870,10 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, // original coordinates and we'll be able to print in full resolution. // Before playback we'll need to counter the scaling up that will happen // in the browser (printed_document_win.cc). - double dynamic_scale = gfx::CalculatePageScale(dc, size_in_pixels.width(), - size_in_pixels.height()); + double dynamic_scale = gfx::CalculatePageScale( + dc, size_in_pixels.width(), size_in_pixels.height()); double page_scale = static_cast<double>(printing::kPointsPerInch) / - static_cast<double>(current_print_settings_.dpi); + static_cast<double>(current_print_settings_.dpi); if (dynamic_scale < page_scale) { page_scale = dynamic_scale; @@ -1883,10 +1883,21 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, gfx::ScaleDC(dc, page_scale); - ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), - 0, dc, current_print_settings_.dpi, - current_print_settings_.dpi, 0, 0, size_in_pixels.width(), - size_in_pixels.height(), true, false, true, true, true); + ret = render_proc(static_cast<unsigned char*>(mapper.data()), + mapper.size(), + 0, + dc, + current_print_settings_.dpi, + current_print_settings_.dpi, + 0, + 0, + size_in_pixels.width(), + size_in_pixels.height(), + true, + false, + true, + true, + true); skia::EndPlatformPaint(canvas); } #endif // defined(OS_WIN) @@ -1967,13 +1978,11 @@ bool PepperPluginInstanceImpl::PrepareTextureMailbox( bool use_shared_memory) { if (!bound_graphics_2d_platform_) return false; - return bound_graphics_2d_platform_->PrepareTextureMailbox( - mailbox, release_callback); + return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox, + release_callback); } -void PepperPluginInstanceImpl::OnDestruct() { - render_frame_ = NULL; -} +void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; } void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { DCHECK(live_plugin_objects_.find(plugin_object) == @@ -2036,7 +2045,8 @@ void PepperPluginInstanceImpl::SimulateInputEvent( view_data_.rect.point.x + view_data_.rect.size.width / 2, view_data_.rect.point.y + view_data_.rect.size.height / 2); for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); - it != events.end(); ++it) { + it != events.end(); + ++it) { web_view->handleInputEvent(*it->get()); } } @@ -2094,14 +2104,13 @@ void PepperPluginInstanceImpl::SimulateImeSetCompositionEvent( } ContentDecryptorDelegate* - PepperPluginInstanceImpl::GetContentDecryptorDelegate() { +PepperPluginInstanceImpl::GetContentDecryptorDelegate() { if (content_decryptor_delegate_) return content_decryptor_delegate_.get(); const PPP_ContentDecryptor_Private* plugin_decryption_interface = static_cast<const PPP_ContentDecryptor_Private*>( - module_->GetPluginInterface( - PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); + module_->GetPluginInterface(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); if (!plugin_decryption_interface) return NULL; @@ -2149,8 +2158,10 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, } EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); - PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? - static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; + PPB_Graphics3D_Impl* graphics_3d = + enter_3d.succeeded() + ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) + : NULL; if (graphics_2d) { if (graphics_2d->BindToInstance(this)) { @@ -2234,11 +2245,11 @@ PP_Var PepperPluginInstanceImpl::ExecuteScript(PP_Instance instance, bool ok = false; if (IsProcessingUserGesture()) { blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); - ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, - &result); + ok = + WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result); } else { - ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, - &result); + ok = + WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result); } if (!ok) { // TryCatch doesn't catch the exceptions properly. Since this is only for @@ -2339,7 +2350,6 @@ void PepperPluginInstanceImpl::DecoderResetDone( content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); } - void PepperPluginInstanceImpl::DeliverFrame( PP_Instance instance, PP_Resource decrypted_frame, @@ -2358,7 +2368,8 @@ void PepperPluginInstanceImpl::SetPluginToHandleFindRequests( PP_Instance instance) { if (!LoadFindInterface()) return; - bool is_main_frame = render_frame_ && + bool is_main_frame = + render_frame_ && render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_; if (!is_main_frame) return; @@ -2397,7 +2408,8 @@ void PepperPluginInstanceImpl::SetTickmarks(PP_Instance instance, tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, tickmarks[i].point.y, tickmarks[i].size.width, - tickmarks[i].size.height);; + tickmarks[i].size.height); + ; } blink::WebFrame* frame = render_frame_->GetWebFrame(); frame->setTickmarks(tickmarks_converted); @@ -2501,8 +2513,8 @@ void PepperPluginInstanceImpl::ZoomLimitsChanged(PP_Instance instance, } double minimum_level = ZoomFactorToZoomLevel(minimum_factor); double maximum_level = ZoomFactorToZoomLevel(maximum_factor); - render_frame_->render_view()->webview()->zoomLimitsChanged( - minimum_level, maximum_level); + render_frame_->render_view()->webview()->zoomLimitsChanged(minimum_level, + maximum_level); } void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, @@ -2649,8 +2661,7 @@ PP_Var PepperPluginInstanceImpl::ResolveRelativeToDocument( WebElement plugin_element = container()->element(); GURL document_url = plugin_element.document().baseURL(); return ppapi::PPB_URLUtil_Shared::GenerateURLReturn( - document_url.Resolve(relative_string->value()), - components); + document_url.Resolve(relative_string->value()), components); } PP_Bool PepperPluginInstanceImpl::DocumentCanRequest(PP_Instance instance, @@ -2695,8 +2706,7 @@ PP_Var PepperPluginInstanceImpl::GetDocumentURL( PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL( PP_Instance instance, PP_URLComponents_Dev* components) { - return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, - components); + return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, components); } PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL( @@ -2759,10 +2769,10 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied( plugin_zoom_interface_ = NULL; // Re-send the DidCreate event via the proxy. - scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); - scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); - if (!instance_interface_->DidCreate(pp_instance(), argn_.size(), - argn_array.get(), argv_array.get())) + scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); + scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); + if (!instance_interface_->DidCreate( + pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; message_channel_->StopQueueingJavaScriptMessages(); @@ -2790,13 +2800,10 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied( bool PepperPluginInstanceImpl::IsValidInstanceOf(PluginModule* module) { DCHECK(module); - return module == module_.get() || - module == original_module_.get(); + return module == module_.get() || module == original_module_.get(); } -NPP PepperPluginInstanceImpl::instanceNPP() { - return npp_.get(); -} +NPP PepperPluginInstanceImpl::instanceNPP() { return npp_.get(); } PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) { return HostGlobals::Get()->GetInstance(instance_id); @@ -2810,17 +2817,13 @@ blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() { return container_; } -v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { - return isolate_; -} +v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { return isolate_; } ppapi::VarTracker* PepperPluginInstanceImpl::GetVarTracker() { return HostGlobals::Get()->GetVarTracker(); } -const GURL& PepperPluginInstanceImpl::GetPluginURL() { - return plugin_url_; -} +const GURL& PepperPluginInstanceImpl::GetPluginURL() { return plugin_url_; } base::FilePath PepperPluginInstanceImpl::GetModulePath() { return module_->path(); @@ -2833,14 +2836,12 @@ PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, if (image_skia_rep.is_null() || image_skia_rep.scale() != scale) return 0; - scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( - pp_instance(), - PPB_ImageData_Impl::PLATFORM)); - if (!image_data->Init( - PPB_ImageData_Impl::GetNativeImageDataFormat(), - image_skia_rep.pixel_width(), - image_skia_rep.pixel_height(), - false)) { + scoped_refptr<PPB_ImageData_Impl> image_data( + new PPB_ImageData_Impl(pp_instance(), PPB_ImageData_Impl::PLATFORM)); + if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(), + image_skia_rep.pixel_width(), + image_skia_rep.pixel_height(), + false)) { return 0; } @@ -2870,14 +2871,13 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy( module_->CreateModuleForExternalPluginInstance()); RendererPpapiHostImpl* renderer_ppapi_host = - external_plugin_module->CreateOutOfProcessModule( - render_frame_, - file_path, - permissions, - channel_handle, - plugin_pid, - plugin_child_id, - true); + external_plugin_module->CreateOutOfProcessModule(render_frame_, + file_path, + permissions, + channel_handle, + plugin_pid, + plugin_child_id, + true); if (!renderer_ppapi_host) { DLOG(ERROR) << "CreateExternalPluginModule() failed"; return PP_EXTERNAL_PLUGIN_ERROR_MODULE; @@ -2919,9 +2919,9 @@ bool PepperPluginInstanceImpl::FlashSetFullscreen(bool fullscreen, if (!render_frame_) return false; - if (fullscreen && - !render_frame_->render_view()->renderer_preferences(). - plugin_fullscreen_allowed) + if (fullscreen && !render_frame_->render_view() + ->renderer_preferences() + .plugin_fullscreen_allowed) return false; // Unbind current 2D or 3D graphics context. @@ -2970,10 +2970,8 @@ int32_t PepperPluginInstanceImpl::Navigate( ppapi::URLRequestInfoData completed_request = request; WebURLRequest web_request; - if (!CreateWebURLRequest(pp_instance_, - &completed_request, - frame, - &web_request)) { + if (!CreateWebURLRequest( + pp_instance_, &completed_request, frame, &web_request)) { return PP_ERROR_FAILED; } web_request.setFirstPartyForCookies(document.firstPartyForCookies()); @@ -2995,8 +2993,7 @@ int32_t PepperPluginInstanceImpl::Navigate( } // Only GETs and POSTs are supported. - if (web_request.httpMethod() != "GET" && - web_request.httpMethod() != "POST") + if (web_request.httpMethod() != "GET" && web_request.httpMethod() != "POST") return PP_ERROR_BADARGUMENT; WebString target_str = WebString::fromUTF8(target); @@ -3013,8 +3010,7 @@ int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); } -void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, - PP_Var value) { +void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, PP_Var value) { message_channel_->SetReadOnlyProperty(key, value); } @@ -3023,8 +3019,7 @@ bool PepperPluginInstanceImpl::CanAccessMainFrame() const { return false; blink::WebDocument containing_document = container_->element().document(); - if (!containing_document.frame() || - !containing_document.frame()->view() || + if (!containing_document.frame() || !containing_document.frame()->view() || !containing_document.frame()->view()->mainFrame()) { return false; } @@ -3090,7 +3085,7 @@ bool PepperPluginInstanceImpl::LockMouse() { } MouseLockDispatcher::LockTarget* - PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() { +PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() { if (!lock_target_.get()) { lock_target_.reset(new PluginInstanceLockTarget(this)); } @@ -3127,11 +3122,13 @@ void PepperPluginInstanceImpl::DidDataFromWebURLResponse( scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource( new ppapi::proxy::URLLoaderResource( host_impl->in_process_router()->GetPluginConnection(pp_instance()), - pp_instance(), pending_host_id, data)); + pp_instance(), + pending_host_id, + data)); PP_Resource loader_pp_resource = loader_resource->GetReference(); - if (!instance_interface_->HandleDocumentLoad( - pp_instance(), loader_pp_resource)) + if (!instance_interface_->HandleDocumentLoad(pp_instance(), + loader_pp_resource)) loader_resource->Close(); // We don't pass a ref into the plugin, if it wants one, it will have taken // an additional one. diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 90f6301..b845923 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -125,11 +125,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // recent version of PPP_Instance possible by querying the given // get_plugin_interface function. If the plugin does not support any valid // PPP_Instance interface, returns NULL. - static PepperPluginInstanceImpl* Create( - RenderFrameImpl* render_frame, - PluginModule* module, - blink::WebPluginContainer* container, - const GURL& plugin_url); + static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, + PluginModule* module, + blink::WebPluginContainer* container, + const GURL& plugin_url); RenderFrameImpl* render_frame() const { return render_frame_; } PluginModule* module() const { return module_.get(); } MessageChannel& message_channel() { return *message_channel_; } @@ -188,7 +187,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl bool HandleInputEvent(const blink::WebInputEvent& event, blink::WebCursorInfo* cursor_info); PP_Var GetInstanceObject(); - void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip, + void ViewChanged(const gfx::Rect& position, + const gfx::Rect& clip, const std::vector<gfx::Rect>& cut_outs_rects); // Handlers for composition events. @@ -321,8 +321,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // Simulates an IME event at the level of RenderView which sends it back up to // the plugin as if it came from the user. bool SimulateIMEEvent(const ppapi::InputEventData& input_event); - void SimulateImeSetCompositionEvent( - const ppapi::InputEventData& input_event); + void SimulateImeSetCompositionEvent(const ppapi::InputEventData& input_event); // The document loader is valid when the plugin is "full-frame" and in this // case is non-NULL as long as the corresponding loader resource is alive. @@ -359,8 +358,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual int32_t Navigate(const ppapi::URLRequestInfoData& request, const char* target, bool from_user_action) OVERRIDE; - virtual int MakePendingFileRefRendererHost( - const base::FilePath& path) OVERRIDE; + virtual int MakePendingFileRefRendererHost(const base::FilePath& path) + OVERRIDE; virtual void SetEmbedProperty(PP_Var key, PP_Var value) OVERRIDE; virtual void SetSelectedText(const base::string16& selected_text) OVERRIDE; virtual void SetLinkUnderCursor(const std::string& url) OVERRIDE; @@ -393,10 +392,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; - virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) - OVERRIDE; + virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; virtual ppapi::Resource* GetSingletonResource(PP_Instance instance, - ppapi::SingletonResourceID id) OVERRIDE; + ppapi::SingletonResourceID id) + OVERRIDE; virtual int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) OVERRIDE; virtual int32_t RequestFilteringInputEvents(PP_Instance instance, @@ -412,9 +411,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl PP_MouseCursor_Type type, PP_Resource image, const PP_Point* hot_spot) OVERRIDE; - virtual int32_t LockMouse( - PP_Instance instance, - scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE; + virtual int32_t LockMouse(PP_Instance instance, + scoped_refptr<ppapi::TrackedCallback> callback) + OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; virtual void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) OVERRIDE; @@ -427,21 +426,21 @@ class CONTENT_EXPORT PepperPluginInstanceImpl const char* text, uint32_t caret, uint32_t anchor) OVERRIDE; - virtual PP_Var ResolveRelativeToDocument( - PP_Instance instance, - PP_Var relative, - PP_URLComponents_Dev* components) OVERRIDE; + virtual PP_Var ResolveRelativeToDocument(PP_Instance instance, + PP_Var relative, + PP_URLComponents_Dev* components) + OVERRIDE; virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE; virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, PP_Instance target) OVERRIDE; virtual PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) OVERRIDE; - virtual PP_Var GetPluginInstanceURL( - PP_Instance instance, - PP_URLComponents_Dev* components) OVERRIDE; - virtual PP_Var GetPluginReferrerURL( - PP_Instance instance, - PP_URLComponents_Dev* components) OVERRIDE; + virtual PP_Var GetPluginInstanceURL(PP_Instance instance, + PP_URLComponents_Dev* components) + OVERRIDE; + virtual PP_Var GetPluginReferrerURL(PP_Instance instance, + PP_URLComponents_Dev* components) + OVERRIDE; // PPB_ContentDecryptor_Private implementation. virtual void SessionCreated(PP_Instance instance, @@ -474,10 +473,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual void DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const PP_DecryptedFrameInfo* frame_info) OVERRIDE; - virtual void DeliverSamples( - PP_Instance instance, - PP_Resource audio_frames, - const PP_DecryptedSampleInfo* sample_info) OVERRIDE; + virtual void DeliverSamples(PP_Instance instance, + PP_Resource audio_frames, + const PP_DecryptedSampleInfo* sample_info) + OVERRIDE; // Reset this instance as proxied. Assigns the instance a new module, resets // cached interfaces to point to the out-of-process proxy and re-sends @@ -549,6 +548,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE; virtual void Sample(PP_Instance instance, PP_GamepadsSampleData* data) OVERRIDE; + private: virtual ~GamepadImpl(); }; @@ -618,9 +618,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl void DoSetCursor(blink::WebCursorInfo* cursor); // Internal helper functions for HandleCompositionXXX(). - bool SendCompositionEventToPlugin( - PP_InputEvent_Type type, - const base::string16& text); + bool SendCompositionEventToPlugin(PP_InputEvent_Type type, + const base::string16& text); bool SendCompositionEventWithUnderlineInformationToPlugin( PP_InputEvent_Type type, const base::string16& text, @@ -651,10 +650,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl MouseLockDispatcher::LockTarget* GetOrCreateLockTargetAdapter(); void UnSetAndDeleteLockTargetAdapter(); - void DidDataFromWebURLResponse( - const blink::WebURLResponse& response, - int pending_host_id, - const ppapi::URLResponseInfoData& data); + void DidDataFromWebURLResponse(const blink::WebURLResponse& response, + int pending_host_id, + const ppapi::URLResponseInfoData& data); RenderFrameImpl* render_frame_; base::Closure instance_deleted_callback_; diff --git a/content/renderer/pepper/pepper_plugin_registry.cc b/content/renderer/pepper/pepper_plugin_registry.cc index 5939ce1..c7a560f 100644 --- a/content/renderer/pepper/pepper_plugin_registry.cc +++ b/content/renderer/pepper/pepper_plugin_registry.cc @@ -82,7 +82,8 @@ void PepperPluginRegistry::PluginModuleDead(PluginModule* dead_module) { // Modules aren't destroyed very often and there are normally at most a // couple of them. So for now we just do a brute-force search. for (NonOwningModuleMap::iterator i = live_modules_.begin(); - i != live_modules_.end(); ++i) { + i != live_modules_.end(); + ++i) { if (i->second == dead_module) { live_modules_.erase(i); return; @@ -100,8 +101,7 @@ PepperPluginRegistry::~PepperPluginRegistry() { DCHECK(live_modules_.empty()); } -PepperPluginRegistry::PepperPluginRegistry() { -} +PepperPluginRegistry::PepperPluginRegistry() {} void PepperPluginRegistry::Initialize() { ComputePepperPluginList(&plugin_list_); @@ -115,9 +115,10 @@ void PepperPluginRegistry::Initialize() { if (current.is_out_of_process) continue; // Out of process plugins need no special pre-initialization. - scoped_refptr<PluginModule> module = new PluginModule( - current.name, current.path, - ppapi::PpapiPermissions(current.permissions)); + scoped_refptr<PluginModule> module = + new PluginModule(current.name, + current.path, + ppapi::PpapiPermissions(current.permissions)); AddLiveModule(current.path, module.get()); if (current.is_internal) { if (!module->InitAsInternalPlugin(current.internal_entry_points)) { diff --git a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc index 738a324..f48e732 100644 --- a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc +++ b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc @@ -9,8 +9,7 @@ namespace content { -PepperProxyChannelDelegateImpl::~PepperProxyChannelDelegateImpl() { -} +PepperProxyChannelDelegateImpl::~PepperProxyChannelDelegateImpl() {} base::MessageLoopProxy* PepperProxyChannelDelegateImpl::GetIPCMessageLoop() { // This is called only in the renderer so we know we have a child process. @@ -28,8 +27,7 @@ PepperProxyChannelDelegateImpl::ShareHandleWithRemote( base::PlatformFile handle, base::ProcessId remote_pid, bool should_close_source) { - return BrokerGetFileHandleForProcess(handle, remote_pid, - should_close_source); + return BrokerGetFileHandleForProcess(handle, remote_pid, should_close_source); } } // namespace content diff --git a/content/renderer/pepper/pepper_truetype_font_host.cc b/content/renderer/pepper/pepper_truetype_font_host.cc index ea9bb12..131c8f2 100644 --- a/content/renderer/pepper/pepper_truetype_font_host.cc +++ b/content/renderer/pepper/pepper_truetype_font_host.cc @@ -26,11 +26,9 @@ PepperTrueTypeFontHost::PepperTrueTypeFontHost( : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), font_(PepperTrueTypeFont::Create(desc)), - weak_factory_(this) { -} + weak_factory_(this) {} -PepperTrueTypeFontHost::~PepperTrueTypeFontHost() { -} +PepperTrueTypeFontHost::~PepperTrueTypeFontHost() {} int32_t PepperTrueTypeFontHost::OnResourceMessageReceived( const IPC::Message& msg, @@ -39,12 +37,12 @@ int32_t PepperTrueTypeFontHost::OnResourceMessageReceived( return PP_ERROR_FAILED; IPC_BEGIN_MESSAGE_MAP(PepperTrueTypeFontHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_Describe, - OnHostMsgDescribe) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_GetTableTags, - OnHostMsgGetTableTags) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TrueTypeFont_GetTable, - OnHostMsgGetTable) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_Describe, + OnHostMsgDescribe) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_GetTableTags, + OnHostMsgGetTableTags) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TrueTypeFont_GetTable, + OnHostMsgGetTable) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -69,9 +67,8 @@ int32_t PepperTrueTypeFontHost::OnHostMsgGetTableTags( std::vector<uint32_t> tags; ReplyMessageContext reply_context = context->MakeReplyMessageContext(); reply_context.params.set_result(font_->GetTableTags(&tags)); - host()->SendReply( - reply_context, - PpapiPluginMsg_TrueTypeFont_GetTableTagsReply(tags)); + host()->SendReply(reply_context, + PpapiPluginMsg_TrueTypeFont_GetTableTagsReply(tags)); return PP_OK_COMPLETIONPENDING; } diff --git a/content/renderer/pepper/pepper_truetype_font_linux.cc b/content/renderer/pepper/pepper_truetype_font_linux.cc index 8fad0de..c54a514 100644 --- a/content/renderer/pepper/pepper_truetype_font_linux.cc +++ b/content/renderer/pepper/pepper_truetype_font_linux.cc @@ -24,13 +24,14 @@ class PepperTrueTypeFontLinux : public PepperTrueTypeFont { // PepperTrueTypeFont overrides. virtual bool IsValid() OVERRIDE; - virtual int32_t Describe( - ppapi::proxy::SerializedTrueTypeFontDesc* desc) OVERRIDE; + virtual int32_t Describe(ppapi::proxy::SerializedTrueTypeFontDesc* desc) + OVERRIDE; virtual int32_t GetTableTags(std::vector<uint32_t>* tags) OVERRIDE; virtual int32_t GetTable(uint32_t table_tag, int32_t offset, int32_t max_data_length, std::string* data) OVERRIDE; + private: // Save creation parameters here and use these to implement Describe. // TODO(bbudge) Modify content API to return results of font matching and @@ -42,8 +43,8 @@ class PepperTrueTypeFontLinux : public PepperTrueTypeFont { }; PepperTrueTypeFontLinux::PepperTrueTypeFontLinux( - const ppapi::proxy::SerializedTrueTypeFontDesc& desc) : - desc_(desc) { + const ppapi::proxy::SerializedTrueTypeFontDesc& desc) + : desc_(desc) { // If no face is provided, convert family to the platform defaults. These // names should be mapped by FontConfig to an appropriate default font. if (desc_.family.empty()) { @@ -66,23 +67,19 @@ PepperTrueTypeFontLinux::PepperTrueTypeFontLinux( } } - fd_ = MatchFontWithFallback( - desc_.family.c_str(), - desc_.weight >= PP_TRUETYPEFONTWEIGHT_BOLD, - desc_.style & PP_TRUETYPEFONTSTYLE_ITALIC, - desc_.charset, - PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT); + fd_ = MatchFontWithFallback(desc_.family.c_str(), + desc_.weight >= PP_TRUETYPEFONTWEIGHT_BOLD, + desc_.style & PP_TRUETYPEFONTSTYLE_ITALIC, + desc_.charset, + PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT); } -PepperTrueTypeFontLinux::~PepperTrueTypeFontLinux() { -} +PepperTrueTypeFontLinux::~PepperTrueTypeFontLinux() {} -bool PepperTrueTypeFontLinux::IsValid() { - return fd_ != -1; -} +bool PepperTrueTypeFontLinux::IsValid() { return fd_ != -1; } int32_t PepperTrueTypeFontLinux::Describe( - ppapi::proxy::SerializedTrueTypeFontDesc* desc) { + ppapi::proxy::SerializedTrueTypeFontDesc* desc) { *desc = desc_; return PP_OK; } @@ -120,7 +117,7 @@ int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector<uint32_t>* tags) { uint8_t* entry = table_entries.get() + i * kTableEntrySize; uint32_t tag = static_cast<uint32_t>(entry[0]) << 24 | static_cast<uint32_t>(entry[1]) << 16 | - static_cast<uint32_t>(entry[2]) << 8 | + static_cast<uint32_t>(entry[2]) << 8 | static_cast<uint32_t>(entry[3]); (*tags)[i] = tag; } @@ -141,7 +138,9 @@ int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag, // Only retrieve as much as the caller requested. table_size = std::min(table_size, static_cast<size_t>(max_data_length)); data->resize(table_size); - if (!GetFontTable(fd_, table_tag, offset, + if (!GetFontTable(fd_, + table_tag, + offset, reinterpret_cast<uint8_t*>(&(*data)[0]), &table_size)) return PP_ERROR_FAILED; @@ -158,4 +157,3 @@ PepperTrueTypeFont* PepperTrueTypeFont::Create( } } // namespace content - diff --git a/content/renderer/pepper/pepper_truetype_font_win.cc b/content/renderer/pepper/pepper_truetype_font_win.cc index edd503a..9b8cdb4 100644 --- a/content/renderer/pepper/pepper_truetype_font_win.cc +++ b/content/renderer/pepper/pepper_truetype_font_win.cc @@ -29,13 +29,14 @@ class PepperTrueTypeFontWin : public PepperTrueTypeFont { // PepperTrueTypeFont overrides. virtual bool IsValid() OVERRIDE; - virtual int32_t Describe( - ppapi::proxy::SerializedTrueTypeFontDesc* desc) OVERRIDE; + virtual int32_t Describe(ppapi::proxy::SerializedTrueTypeFontDesc* desc) + OVERRIDE; virtual int32_t GetTableTags(std::vector<uint32_t>* tags) OVERRIDE; virtual int32_t GetTable(uint32_t table_tag, int32_t offset, int32_t max_data_length, std::string* data) OVERRIDE; + private: DWORD GetFontData(HDC hdc, DWORD table, @@ -70,15 +71,15 @@ PepperTrueTypeFontWin::PepperTrueTypeFontWin( } // TODO(bbudge) support widths (extended, condensed). - font_ = CreateFont(0 /* height */, - 0 /* width */, - 0 /* escapement */, - 0 /* orientation */, + font_ = CreateFont(0 /* height */, + 0 /* width */, + 0 /* escapement */, + 0 /* orientation */, desc.weight, // our weight enum matches Windows. (desc.style & PP_TRUETYPEFONTSTYLE_ITALIC) ? 1 : 0, - 0 /* underline */, - 0 /* strikeout */, - desc.charset, // our charset enum matches Windows. + 0 /* underline */, + 0 /* strikeout */, + desc.charset, // our charset enum matches Windows. OUT_OUTLINE_PRECIS, // truetype and other outline fonts CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, @@ -86,15 +87,12 @@ PepperTrueTypeFontWin::PepperTrueTypeFontWin( base::UTF8ToUTF16(desc.family).c_str()); } -PepperTrueTypeFontWin::~PepperTrueTypeFontWin() { -} +PepperTrueTypeFontWin::~PepperTrueTypeFontWin() {} -bool PepperTrueTypeFontWin::IsValid() { - return font_ != NULL; -} +bool PepperTrueTypeFontWin::IsValid() { return font_ != NULL; } int32_t PepperTrueTypeFontWin::Describe( - ppapi::proxy::SerializedTrueTypeFontDesc* desc) { + ppapi::proxy::SerializedTrueTypeFontDesc* desc) { LOGFONT font_desc; if (!::GetObject(font_, sizeof(LOGFONT), &font_desc)) return PP_ERROR_FAILED; @@ -117,12 +115,11 @@ int32_t PepperTrueTypeFontWin::Describe( break; } - desc->style = font_desc.lfItalic ? PP_TRUETYPEFONTSTYLE_ITALIC : - PP_TRUETYPEFONTSTYLE_NORMAL; + desc->style = font_desc.lfItalic ? PP_TRUETYPEFONTSTYLE_ITALIC + : PP_TRUETYPEFONTSTYLE_NORMAL; desc->weight = static_cast<PP_TrueTypeFontWeight_Dev>(font_desc.lfWeight); desc->width = PP_TRUETYPEFONTWIDTH_NORMAL; - desc->charset = - static_cast<PP_TrueTypeFontCharset_Dev>(font_desc.lfCharSet); + desc->charset = static_cast<PP_TrueTypeFontCharset_Dev>(font_desc.lfCharSet); // To get the face name, select the font and query for the name. GetObject // doesn't fill in the name field of the LOGFONT structure. @@ -184,9 +181,9 @@ int32_t PepperTrueTypeFontWin::GetTableTags(std::vector<uint32_t>* tags) { DWORD directory_size = num_tables * kDirectoryEntrySize; scoped_ptr<uint8_t[]> directory(new uint8_t[directory_size]); // Get the table directory entries after the font header. - if (GetFontData(hdc, 0 /* tag */, kFontHeaderSize, - directory.get(), - directory_size) == GDI_ERROR) + if (GetFontData( + hdc, 0 /* tag */, kFontHeaderSize, directory.get(), directory_size) == + GDI_ERROR) return PP_ERROR_FAILED; tags->resize(num_tables); @@ -194,7 +191,7 @@ int32_t PepperTrueTypeFontWin::GetTableTags(std::vector<uint32_t>* tags) { const uint8_t* entry = directory.get() + i * kDirectoryEntrySize; uint32_t tag = static_cast<uint32_t>(entry[0]) << 24 | static_cast<uint32_t>(entry[1]) << 16 | - static_cast<uint32_t>(entry[2]) << 8 | + static_cast<uint32_t>(entry[2]) << 8 | static_cast<uint32_t>(entry[3]); (*tags)[i] = tag; } @@ -220,13 +217,15 @@ int32_t PepperTrueTypeFontWin::GetTable(uint32_t table_tag, return PP_ERROR_FAILED; DWORD safe_offset = std::min(static_cast<DWORD>(offset), table_size); - DWORD safe_length = std::min(table_size - safe_offset, - static_cast<DWORD>(max_data_length)); + DWORD safe_length = + std::min(table_size - safe_offset, static_cast<DWORD>(max_data_length)); data->resize(safe_length); if (safe_length == 0) { table_size = 0; } else { - table_size = GetFontData(hdc, table_tag, safe_offset, + table_size = GetFontData(hdc, + table_tag, + safe_offset, reinterpret_cast<uint8_t*>(&(*data)[0]), safe_length); if (table_size == GDI_ERROR) diff --git a/content/renderer/pepper/pepper_url_loader_host.cc b/content/renderer/pepper/pepper_url_loader_host.cc index 924ec02..f791189 100644 --- a/content/renderer/pepper/pepper_url_loader_host.cc +++ b/content/renderer/pepper/pepper_url_loader_host.cc @@ -104,18 +104,14 @@ int32_t PepperURLLoaderHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_URLLoader_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_URLLoader_SetDeferLoading, - OnHostMsgSetDeferLoading) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_URLLoader_Close, - OnHostMsgClose); - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_URLLoader_GrantUniversalAccess, - OnHostMsgGrantUniversalAccess) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_Open, OnHostMsgOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_SetDeferLoading, + OnHostMsgSetDeferLoading) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_URLLoader_Close, + OnHostMsgClose); + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_URLLoader_GrantUniversalAccess, + OnHostMsgGrantUniversalAccess) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -179,7 +175,7 @@ void PepperURLLoaderHost::didFinishLoading(WebURLLoader* loader, } void PepperURLLoaderHost::didFail(WebURLLoader* loader, - const WebURLError& error) { + const WebURLError& error) { // Note that |loader| will be NULL for document loads. int32_t pp_error = PP_ERROR_FAILED; if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain))) { @@ -236,7 +232,9 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( if (URLRequestRequiresUniversalAccess(filled_in_request_data) && !has_universal_access_) { ppapi::PpapiGlobals::Get()->LogWithSource( - pp_instance(), PP_LOGLEVEL_ERROR, std::string(), + pp_instance(), + PP_LOGLEVEL_ERROR, + std::string(), "PPB_URLLoader.Open: The URL you're requesting is " " on a different security origin than your plugin. To request " " cross-origin resources, see " @@ -252,10 +250,8 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( return PP_ERROR_FAILED; WebURLRequest web_request; - if (!CreateWebURLRequest(pp_instance(), - &filled_in_request_data, - frame, - &web_request)) { + if (!CreateWebURLRequest( + pp_instance(), &filled_in_request_data, frame, &web_request)) { return PP_ERROR_FAILED; } @@ -401,7 +397,7 @@ void PepperURLLoaderHost::SaveResponse(const WebURLResponse& response) { pp_instance(), response, base::Bind(&PepperURLLoaderHost::DidDataFromWebURLResponse, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr())); } } @@ -421,10 +417,10 @@ void PepperURLLoaderHost::UpdateProgress() { // flag. ppapi::proxy::ResourceMessageReplyParams params; SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( - record_upload ? bytes_sent_ : -1, - record_upload ? total_bytes_to_be_sent_ : -1, - record_download ? bytes_received_ : -1, - record_download ? total_bytes_to_be_received_ : -1)); + record_upload ? bytes_sent_ : -1, + record_upload ? total_bytes_to_be_sent_ : -1, + record_download ? bytes_received_ : -1, + record_download ? total_bytes_to_be_received_ : -1)); } } diff --git a/content/renderer/pepper/pepper_url_loader_host.h b/content/renderer/pepper/pepper_url_loader_host.h index 98f526e..640011b 100644 --- a/content/renderer/pepper/pepper_url_loader_host.h +++ b/content/renderer/pepper/pepper_url_loader_host.h @@ -25,9 +25,8 @@ namespace content { class RendererPpapiHostImpl; -class PepperURLLoaderHost - : public ppapi::host::ResourceHost, - public blink::WebURLLoaderClient { +class PepperURLLoaderHost : public ppapi::host::ResourceHost, + public blink::WebURLLoaderClient { public: // If main_document_loader is true, PP_Resource must be 0 since it will be // pending until the plugin resource attaches to it. diff --git a/content/renderer/pepper/pepper_url_request_unittest.cc b/content/renderer/pepper/pepper_url_request_unittest.cc index 92336aa..44936c2 100644 --- a/content/renderer/pepper/pepper_url_request_unittest.cc +++ b/content/renderer/pepper/pepper_url_request_unittest.cc @@ -42,8 +42,7 @@ bool IsExpected(const WebString& web_string, const char* expected) { } // The base class destructor is protected, so derive. -class TestWebFrameClient : public WebFrameClient { -}; +class TestWebFrameClient : public WebFrameClient {}; } // namespace @@ -54,8 +53,7 @@ namespace content { class URLRequestInfoTest : public RenderViewTest { public: - URLRequestInfoTest() : pp_instance_(1234) { - } + URLRequestInfoTest() : pp_instance_(1234) {} virtual void SetUp() OVERRIDE { RenderViewTest::SetUp(); @@ -64,9 +62,8 @@ class URLRequestInfoTest : public RenderViewTest { test_globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); // This resource doesn't do IPC, so a null connection is fine. - info_ = new URLRequestInfoResource(ppapi::proxy::Connection(), - pp_instance_, - URLRequestInfoData()); + info_ = new URLRequestInfoResource( + ppapi::proxy::Connection(), pp_instance_, URLRequestInfoData()); } virtual void TearDown() OVERRIDE { @@ -141,79 +138,73 @@ TEST_F(URLRequestInfoTest, StreamToFile) { EXPECT_FALSE(GetDownloadToFile()); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_STREAMTOFILE, true)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, true)); EXPECT_TRUE(GetDownloadToFile()); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_STREAMTOFILE, false)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, false)); EXPECT_FALSE(GetDownloadToFile()); } TEST_F(URLRequestInfoTest, FollowRedirects) { EXPECT_TRUE(info_->GetData().follow_redirects); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, false)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, false)); EXPECT_FALSE(info_->GetData().follow_redirects); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, true)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, true)); EXPECT_TRUE(info_->GetData().follow_redirects); } TEST_F(URLRequestInfoTest, RecordDownloadProgress) { EXPECT_FALSE(info_->GetData().record_download_progress); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, true)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, true)); EXPECT_TRUE(info_->GetData().record_download_progress); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, false)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, false)); EXPECT_FALSE(info_->GetData().record_download_progress); } TEST_F(URLRequestInfoTest, RecordUploadProgress) { EXPECT_FALSE(info_->GetData().record_upload_progress); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, true)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, true)); EXPECT_TRUE(info_->GetData().record_upload_progress); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, false)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, false)); EXPECT_FALSE(info_->GetData().record_upload_progress); } TEST_F(URLRequestInfoTest, AllowCrossOriginRequests) { EXPECT_FALSE(info_->GetData().allow_cross_origin_requests); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, true)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, true)); EXPECT_TRUE(info_->GetData().allow_cross_origin_requests); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, false)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, + false)); EXPECT_FALSE(info_->GetData().allow_cross_origin_requests); } TEST_F(URLRequestInfoTest, AllowCredentials) { EXPECT_FALSE(info_->GetData().allow_credentials); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, true)); + EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, true)); EXPECT_TRUE(info_->GetData().allow_credentials); - EXPECT_TRUE(SetBooleanProperty( - PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, false)); + EXPECT_TRUE( + SetBooleanProperty(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, false)); EXPECT_FALSE(info_->GetData().allow_credentials); } TEST_F(URLRequestInfoTest, SetURL) { const char* url = "http://www.google.com/"; - EXPECT_TRUE(SetStringProperty( - PP_URLREQUESTPROPERTY_URL, url)); + EXPECT_TRUE(SetStringProperty(PP_URLREQUESTPROPERTY_URL, url)); EXPECT_TRUE(IsExpected(GetURL(), url)); } @@ -227,27 +218,21 @@ TEST_F(URLRequestInfoTest, JavascriptURL) { TEST_F(URLRequestInfoTest, SetMethod) { // Test default method is "GET". EXPECT_TRUE(IsExpected(GetMethod(), "GET")); - EXPECT_TRUE(SetStringProperty( - PP_URLREQUESTPROPERTY_METHOD, "POST")); + EXPECT_TRUE(SetStringProperty(PP_URLREQUESTPROPERTY_METHOD, "POST")); EXPECT_TRUE(IsExpected(GetMethod(), "POST")); } TEST_F(URLRequestInfoTest, SetHeaders) { // Test default header field. - EXPECT_TRUE(IsExpected( - GetHeaderValue("foo"), "")); + EXPECT_TRUE(IsExpected(GetHeaderValue("foo"), "")); // Test that we can set a header field. - EXPECT_TRUE(SetStringProperty( - PP_URLREQUESTPROPERTY_HEADERS, "foo: bar")); - EXPECT_TRUE(IsExpected( - GetHeaderValue("foo"), "bar")); + EXPECT_TRUE(SetStringProperty(PP_URLREQUESTPROPERTY_HEADERS, "foo: bar")); + EXPECT_TRUE(IsExpected(GetHeaderValue("foo"), "bar")); // Test that we can set multiple header fields using \n delimiter. - EXPECT_TRUE(SetStringProperty( - PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\nbar: baz")); - EXPECT_TRUE(IsExpected( - GetHeaderValue("foo"), "bar")); - EXPECT_TRUE(IsExpected( - GetHeaderValue("bar"), "baz")); + EXPECT_TRUE( + SetStringProperty(PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\nbar: baz")); + EXPECT_TRUE(IsExpected(GetHeaderValue("foo"), "bar")); + EXPECT_TRUE(IsExpected(GetHeaderValue("bar"), "baz")); } // TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody. diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc index 33c3939..acafcbe 100644 --- a/content/renderer/pepper/pepper_video_capture_host.cc +++ b/content/renderer/pepper/pepper_video_capture_host.cc @@ -41,17 +41,13 @@ PepperVideoCaptureHost::PepperVideoCaptureHost(RendererPpapiHostImpl* host, renderer_ppapi_host_(host), buffer_count_hint_(0), status_(PP_VIDEO_CAPTURE_STATUS_STOPPED), - enumeration_helper_( - this, - PepperMediaDeviceManager::GetForRenderView( - host->GetRenderViewForInstance(pp_instance())), - PP_DEVICETYPE_DEV_VIDEOCAPTURE, - host->GetDocumentURL(instance)) { -} + enumeration_helper_(this, + PepperMediaDeviceManager::GetForRenderView( + host->GetRenderViewForInstance(pp_instance())), + PP_DEVICETYPE_DEV_VIDEOCAPTURE, + host->GetDocumentURL(instance)) {} -PepperVideoCaptureHost::~PepperVideoCaptureHost() { - Close(); -} +PepperVideoCaptureHost::~PepperVideoCaptureHost() { Close(); } bool PepperVideoCaptureHost::Init() { return !!renderer_ppapi_host_->GetPluginInstance(pp_instance()); @@ -65,21 +61,14 @@ int32_t PepperVideoCaptureHost::OnResourceMessageReceived( return result; IPC_BEGIN_MESSAGE_MAP(PepperVideoCaptureHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_VideoCapture_Open, - OnOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_VideoCapture_StartCapture, - OnStartCapture) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_VideoCapture_ReuseBuffer, - OnReuseBuffer) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_VideoCapture_StopCapture, - OnStopCapture) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_VideoCapture_Close, - OnClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoCapture_Open, OnOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoCapture_StartCapture, + OnStartCapture) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoCapture_ReuseBuffer, + OnReuseBuffer) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoCapture_StopCapture, + OnStopCapture) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoCapture_Close, OnClose) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -126,12 +115,11 @@ void PepperVideoCaptureHost::PostErrorReply() { // conflicting "master" resolution), or because the browser failed to start // the capture. SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPED, true); - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_VideoCapture_OnError(PP_ERROR_FAILED)); + host()->SendUnsolicitedReply( + pp_resource(), PpapiPluginMsg_VideoCapture_OnError(PP_ERROR_FAILED)); } -void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) { -} +void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) {} void PepperVideoCaptureHost::OnFrameReady( media::VideoCapture* capture, @@ -168,21 +156,19 @@ void PepperVideoCaptureHost::OnFrameReady( } } buffers_[i].in_use = true; - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_VideoCapture_OnBufferReady(i)); + host()->SendUnsolicitedReply( + pp_resource(), PpapiPluginMsg_VideoCapture_OnBufferReady(i)); return; } } } -void PepperVideoCaptureHost::AllocBuffers( - const gfx::Size& resolution, - int frame_rate) { +void PepperVideoCaptureHost::AllocBuffers(const gfx::Size& resolution, + int frame_rate) { PP_VideoCaptureDeviceInfo_Dev info = { - static_cast<uint32_t>(resolution.width()), - static_cast<uint32_t>(resolution.height()), - static_cast<uint32_t>(frame_rate) - }; + static_cast<uint32_t>(resolution.width()), + static_cast<uint32_t>(resolution.height()), + static_cast<uint32_t>(frame_rate)}; ReleaseBuffers(); const size_t size = media::VideoFrame::AllocationSize( @@ -195,8 +181,7 @@ void PepperVideoCaptureHost::AllocBuffers( // for sending below. std::vector<HostResource> buffer_host_resources; buffers_.reserve(buffer_count_hint_); - ppapi::ResourceTracker* tracker = - HostGlobals::Get()->GetResourceTracker(); + ppapi::ResourceTracker* tracker = HostGlobals::Get()->GetResourceTracker(); ppapi::proxy::HostDispatcher* dispatcher = ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); for (size_t i = 0; i < buffer_count_hint_; ++i) { @@ -244,10 +229,8 @@ void PepperVideoCaptureHost::AllocBuffers( #else #error Not implemented. #endif - params.AppendHandle( - ppapi::proxy::SerializedHandle( - dispatcher->ShareHandleWithRemote(platform_file, false), - size)); + params.AppendHandle(ppapi::proxy::SerializedHandle( + dispatcher->ShareHandleWithRemote(platform_file, false), size)); } } @@ -260,9 +243,10 @@ void PepperVideoCaptureHost::AllocBuffers( return; } - host()->Send(new PpapiPluginMsg_ResourceReply( - params, PpapiPluginMsg_VideoCapture_OnDeviceInfo( - info, buffer_host_resources, size))); + host()->Send( + new PpapiPluginMsg_ResourceReply(params, + PpapiPluginMsg_VideoCapture_OnDeviceInfo( + info, buffer_host_resources, size))); } int32_t PepperVideoCaptureHost::OnOpen( @@ -283,8 +267,7 @@ int32_t PepperVideoCaptureHost::OnOpen( renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); platform_video_capture_ = new PepperPlatformVideoCapture( - render_view->AsWeakPtr(), device_id, - document_url, this); + render_view->AsWeakPtr(), device_id, document_url, this); open_reply_context_ = context->MakeReplyMessageContext(); @@ -358,7 +341,7 @@ void PepperVideoCaptureHost::ReleaseBuffers() { void PepperVideoCaptureHost::SendStatus() { host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_VideoCapture_OnStatus(status_)); + PpapiPluginMsg_VideoCapture_OnStatus(status_)); } void PepperVideoCaptureHost::SetRequestedInfo( @@ -433,12 +416,8 @@ bool PepperVideoCaptureHost::SetStatus(PP_VideoCaptureStatus_Dev status, } PepperVideoCaptureHost::BufferInfo::BufferInfo() - : in_use(false), - data(NULL), - buffer() { -} + : in_use(false), data(NULL), buffer() {} -PepperVideoCaptureHost::BufferInfo::~BufferInfo() { -} +PepperVideoCaptureHost::BufferInfo::~BufferInfo() {} } // namespace content diff --git a/content/renderer/pepper/pepper_video_capture_host.h b/content/renderer/pepper/pepper_video_capture_host.h index a8312a2..8f5b77a 100644 --- a/content/renderer/pepper/pepper_video_capture_host.h +++ b/content/renderer/pepper/pepper_video_capture_host.h @@ -20,9 +20,8 @@ namespace content { class PepperPlatformVideoCapture; class RendererPpapiHostImpl; -class PepperVideoCaptureHost - : public ppapi::host::ResourceHost, - public media::VideoCapture::EventHandler { +class PepperVideoCaptureHost : public ppapi::host::ResourceHost, + public media::VideoCapture::EventHandler { public: PepperVideoCaptureHost(RendererPpapiHostImpl* host, PP_Instance instance, @@ -44,9 +43,9 @@ class PepperVideoCaptureHost virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; - virtual void OnFrameReady( - media::VideoCapture* capture, - const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; + virtual void OnFrameReady(media::VideoCapture* capture, + const scoped_refptr<media::VideoFrame>& frame) + OVERRIDE; private: int32_t OnOpen(ppapi::host::HostMessageContext* context, @@ -62,8 +61,7 @@ class PepperVideoCaptureHost int32_t StopCapture(); int32_t Close(); void PostErrorReply(); - void AllocBuffers(const gfx::Size& resolution, - int frame_rate); + void AllocBuffers(const gfx::Size& resolution, int frame_rate); void ReleaseBuffers(); void SendStatus(); diff --git a/content/renderer/pepper/pepper_video_destination_host.cc b/content/renderer/pepper/pepper_video_destination_host.cc index 4c19b90..63eb27a 100644 --- a/content/renderer/pepper/pepper_video_destination_host.cc +++ b/content/renderer/pepper/pepper_video_destination_host.cc @@ -20,28 +20,25 @@ using ppapi::host::ReplyMessageContext; namespace content { -PepperVideoDestinationHost::PepperVideoDestinationHost( - RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) +PepperVideoDestinationHost::PepperVideoDestinationHost(RendererPpapiHost* host, + PP_Instance instance, + PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), - weak_factory_(this) { -} + weak_factory_(this) {} -PepperVideoDestinationHost::~PepperVideoDestinationHost() { -} +PepperVideoDestinationHost::~PepperVideoDestinationHost() {} int32_t PepperVideoDestinationHost::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, - OnHostMsgPutFrame) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, - OnHostMsgClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, + OnHostMsgOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, + OnHostMsgPutFrame) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, + OnHostMsgClose) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -54,17 +51,14 @@ int32_t PepperVideoDestinationHost::OnHostMsgOpen( return PP_ERROR_BADARGUMENT; FrameWriterInterface* frame_writer = NULL; - if (!VideoDestinationHandler::Open(NULL /* factory */, - NULL /* registry */, - gurl.spec(), - &frame_writer)) + if (!VideoDestinationHandler::Open( + NULL /* factory */, NULL /* registry */, gurl.spec(), &frame_writer)) return PP_ERROR_FAILED; frame_writer_.reset(frame_writer); ReplyMessageContext reply_context = context->MakeReplyMessageContext(); reply_context.params.set_result(PP_OK); - host()->SendReply(reply_context, - PpapiPluginMsg_VideoDestination_OpenReply()); + host()->SendReply(reply_context, PpapiPluginMsg_VideoDestination_OpenReply()); return PP_OK_COMPLETIONPENDING; } diff --git a/content/renderer/pepper/pepper_video_source_host.cc b/content/renderer/pepper/pepper_video_source_host.cc index 9996ec9..c8eaf63 100644 --- a/content/renderer/pepper/pepper_video_source_host.cc +++ b/content/renderer/pepper/pepper_video_source_host.cc @@ -28,21 +28,16 @@ namespace content { PepperVideoSourceHost::FrameReceiver::FrameReceiver( const base::WeakPtr<PepperVideoSourceHost>& host) : host_(host), - main_message_loop_proxy_(base::MessageLoopProxy::current()) { -} + main_message_loop_proxy_(base::MessageLoopProxy::current()) {} -PepperVideoSourceHost::FrameReceiver::~FrameReceiver() { -} +PepperVideoSourceHost::FrameReceiver::~FrameReceiver() {} bool PepperVideoSourceHost::FrameReceiver::GotFrame( const scoped_refptr<media::VideoFrame>& frame) { // It's not safe to access the host from this thread, so post a task to our // main thread to transfer the new frame. main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&FrameReceiver::OnGotFrame, - this, - frame)); + FROM_HERE, base::Bind(&FrameReceiver::OnGotFrame, this, frame)); return true; } @@ -58,10 +53,9 @@ void PepperVideoSourceHost::FrameReceiver::OnGotFrame( } } -PepperVideoSourceHost::PepperVideoSourceHost( - RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) +PepperVideoSourceHost::PepperVideoSourceHost(RendererPpapiHost* host, + PP_Instance instance, + PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), source_handler_(new VideoSourceHandler(NULL)), @@ -70,20 +64,18 @@ PepperVideoSourceHost::PepperVideoSourceHost( frame_receiver_ = new FrameReceiver(weak_factory_.GetWeakPtr()); } -PepperVideoSourceHost::~PepperVideoSourceHost() { - Close(); -} +PepperVideoSourceHost::~PepperVideoSourceHost() { Close(); } int32_t PepperVideoSourceHost::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperVideoSourceHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoSource_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_GetFrame, - OnHostMsgGetFrame) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_Close, - OnHostMsgClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoSource_Open, + OnHostMsgOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_GetFrame, + OnHostMsgGetFrame) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_Close, + OnHostMsgClose) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -148,7 +140,9 @@ void PepperVideoSourceHost::SendGetFrameReply() { PP_IMAGEDATAFORMAT_BGRA_PREMUL, PP_MakeSize(dst_width, dst_height), false /* init_to_zero */, - &image_desc, &image_handle, &byte_count)); + &image_desc, + &image_handle, + &byte_count)); if (!resource.get()) { SendGetFrameErrorReply(PP_ERROR_FAILED); return; @@ -191,12 +185,12 @@ void PepperVideoSourceHost::SendGetFrameReply() { const int vert_crop = frame->visible_rect().y(); const uint8* src_y = frame->data(media::VideoFrame::kYPlane) + - (src_width * vert_crop + horiz_crop); + (src_width * vert_crop + horiz_crop); const int center = (src_width + 1) / 2; const uint8* src_u = frame->data(media::VideoFrame::kUPlane) + - (center * vert_crop + horiz_crop) / 2; + (center * vert_crop + horiz_crop) / 2; const uint8* src_v = frame->data(media::VideoFrame::kVPlane) + - (center * vert_crop + horiz_crop) / 2; + (center * vert_crop + horiz_crop) / 2; libyuv::I420ToBGRA(src_y, frame->stride(media::VideoFrame::kYPlane), @@ -204,8 +198,10 @@ void PepperVideoSourceHost::SendGetFrameReply() { frame->stride(media::VideoFrame::kUPlane), src_v, frame->stride(media::VideoFrame::kVPlane), - bitmap_pixels, bitmap->rowBytes(), - dst_width, dst_height); + bitmap_pixels, + bitmap->rowBytes(), + dst_width, + dst_height); ppapi::HostResource host_resource; host_resource.SetHostResource(pp_instance(), resource.get()); @@ -218,9 +214,8 @@ void PepperVideoSourceHost::SendGetFrameReply() { reply_context_.params.AppendHandle(serialized_handle); host()->SendReply(reply_context_, - PpapiPluginMsg_VideoSource_GetFrameReply(host_resource, - image_desc, - timestamp)); + PpapiPluginMsg_VideoSource_GetFrameReply( + host_resource, image_desc, timestamp)); reply_context_ = ppapi::host::ReplyMessageContext(); @@ -232,9 +227,8 @@ void PepperVideoSourceHost::SendGetFrameErrorReply(int32_t error) { reply_context_.params.set_result(error); host()->SendReply( reply_context_, - PpapiPluginMsg_VideoSource_GetFrameReply(ppapi::HostResource(), - PP_ImageDataDesc(), - 0.0 /* timestamp */)); + PpapiPluginMsg_VideoSource_GetFrameReply( + ppapi::HostResource(), PP_ImageDataDesc(), 0.0 /* timestamp */)); reply_context_ = ppapi::host::ReplyMessageContext(); } diff --git a/content/renderer/pepper/pepper_video_source_host.h b/content/renderer/pepper/pepper_video_source_host.h index 6810aa6..a1414ce 100644 --- a/content/renderer/pepper/pepper_video_source_host.h +++ b/content/renderer/pepper/pepper_video_source_host.h @@ -42,8 +42,8 @@ class CONTENT_EXPORT PepperVideoSourceHost : public ppapi::host::ResourceHost { explicit FrameReceiver(const base::WeakPtr<PepperVideoSourceHost>& host); // FrameReaderInterface implementation. - virtual bool GotFrame( - const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; + virtual bool GotFrame(const scoped_refptr<media::VideoFrame>& frame) + OVERRIDE; void OnGotFrame(const scoped_refptr<media::VideoFrame>& frame); diff --git a/content/renderer/pepper/pepper_webplugin_impl.cc b/content/renderer/pepper/pepper_webplugin_impl.cc index 1cd2850..828da7a 100644 --- a/content/renderer/pepper/pepper_webplugin_impl.cc +++ b/content/renderer/pepper/pepper_webplugin_impl.cc @@ -54,10 +54,9 @@ struct PepperWebPluginImpl::InitData { GURL url; }; -PepperWebPluginImpl::PepperWebPluginImpl( - PluginModule* plugin_module, - const WebPluginParams& params, - RenderFrameImpl* render_frame) +PepperWebPluginImpl::PepperWebPluginImpl(PluginModule* plugin_module, + const WebPluginParams& params, + RenderFrameImpl* render_frame) : init_data_(new InitData()), full_frame_(params.loadManually), instance_object_(PP_MakeUndefined()), @@ -75,8 +74,7 @@ PepperWebPluginImpl::PepperWebPluginImpl( base::debug::SetCrashKeyValue("subresource_url", init_data_->url.spec()); } -PepperWebPluginImpl::~PepperWebPluginImpl() { -} +PepperWebPluginImpl::~PepperWebPluginImpl() {} blink::WebPluginContainer* PepperWebPluginImpl::container() const { return container_; @@ -92,9 +90,8 @@ bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { // Enable script objects for this plugin. container->allowScriptObjects(); - bool success = instance_->Initialize(init_data_->arg_names, - init_data_->arg_values, - full_frame_); + bool success = instance_->Initialize( + init_data_->arg_names, init_data_->arg_values, full_frame_); if (!success) { instance_->Delete(); instance_ = NULL; @@ -151,13 +148,9 @@ NPObject* PepperWebPluginImpl::scriptableObject() { return message_channel_np_object; } -NPP PepperWebPluginImpl::pluginNPP() { - return instance_->instanceNPP(); -} +NPP PepperWebPluginImpl::pluginNPP() { return instance_->instanceNPP(); } -bool PepperWebPluginImpl::getFormValue(WebString& value) { - return false; -} +bool PepperWebPluginImpl::getFormValue(WebString& value) { return false; } void PepperWebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { if (!instance_->FlashIsFullscreenOrPending()) @@ -182,12 +175,9 @@ void PepperWebPluginImpl::updateFocus(bool focused) { instance_->SetWebKitFocus(focused); } -void PepperWebPluginImpl::updateVisibility(bool visible) { -} +void PepperWebPluginImpl::updateVisibility(bool visible) {} -bool PepperWebPluginImpl::acceptsInputEvents() { - return true; -} +bool PepperWebPluginImpl::acceptsInputEvents() { return true; } bool PepperWebPluginImpl::handleInputEvent(const blink::WebInputEvent& event, blink::WebCursorInfo& cursor_info) { @@ -211,8 +201,8 @@ void PepperWebPluginImpl::didReceiveData(const char* data, int data_length) { void PepperWebPluginImpl::didFinishLoading() { blink::WebURLLoaderClient* document_loader = instance_->document_loader(); if (document_loader) - document_loader->didFinishLoading(NULL, 0.0, - blink::WebURLLoaderClient::kUnknownEncodedDataLength); + document_loader->didFinishLoading( + NULL, 0.0, blink::WebURLLoaderClient::kUnknownEncodedDataLength); } void PepperWebPluginImpl::didFailLoading(const blink::WebURLError& error) { @@ -221,16 +211,13 @@ void PepperWebPluginImpl::didFailLoading(const blink::WebURLError& error) { document_loader->didFail(NULL, error); } -void PepperWebPluginImpl::didFinishLoadingFrameRequest( - const blink::WebURL& url, - void* notify_data) { -} +void PepperWebPluginImpl::didFinishLoadingFrameRequest(const blink::WebURL& url, + void* notify_data) {} void PepperWebPluginImpl::didFailLoadingFrameRequest( const blink::WebURL& url, void* notify_data, - const blink::WebURLError& error) { -} + const blink::WebURLError& error) {} bool PepperWebPluginImpl::hasSelection() const { return !selectionAsText().isEmpty(); @@ -262,9 +249,7 @@ void PepperWebPluginImpl::selectFindResult(bool forward) { instance_->SelectFindResult(forward); } -void PepperWebPluginImpl::stopFind() { - instance_->StopFind(); -} +void PepperWebPluginImpl::stopFind() { instance_->StopFind(); } bool PepperWebPluginImpl::supportsPaginatedPrint() { return instance_->SupportsPrintInterface(); @@ -278,25 +263,18 @@ int PepperWebPluginImpl::printBegin(const WebPrintParams& print_params) { return instance_->PrintBegin(print_params); } -bool PepperWebPluginImpl::printPage(int page_number, - blink::WebCanvas* canvas) { +bool PepperWebPluginImpl::printPage(int page_number, blink::WebCanvas* canvas) { return instance_->PrintPage(page_number, canvas); } -void PepperWebPluginImpl::printEnd() { - return instance_->PrintEnd(); -} +void PepperWebPluginImpl::printEnd() { return instance_->PrintEnd(); } -bool PepperWebPluginImpl::canRotateView() { - return instance_->CanRotateView(); -} +bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } void PepperWebPluginImpl::rotateView(RotationType type) { instance_->RotateView(type); } -bool PepperWebPluginImpl::isPlaceholder() { - return false; -} +bool PepperWebPluginImpl::isPlaceholder() { return false; } } // namespace content diff --git a/content/renderer/pepper/pepper_websocket_host.cc b/content/renderer/pepper/pepper_websocket_host.cc index 7df7796..e5bfe7a 100644 --- a/content/renderer/pepper/pepper_websocket_host.cc +++ b/content/renderer/pepper/pepper_websocket_host.cc @@ -30,10 +30,10 @@ using blink::WebURL; namespace content { -#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ - COMPILE_ASSERT(static_cast<int>(WebSocket::webkit_name) \ - == static_cast<int>(np_name), \ - mismatching_enums) +#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ + COMPILE_ASSERT( \ + static_cast<int>(WebSocket::webkit_name) == static_cast<int>(np_name), \ + mismatching_enums) COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNormalClosure, PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE); @@ -64,17 +64,15 @@ COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMinimumUserDefined, COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMaximumUserDefined, PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX); -PepperWebSocketHost::PepperWebSocketHost( - RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) +PepperWebSocketHost::PepperWebSocketHost(RendererPpapiHost* host, + PP_Instance instance, + PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), renderer_ppapi_host_(host), connecting_(false), initiating_close_(false), accepting_close_(false), - error_was_received_(false) { -} + error_was_received_(false) {} PepperWebSocketHost::~PepperWebSocketHost() { if (websocket_) @@ -85,16 +83,15 @@ int32_t PepperWebSocketHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperWebSocketHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Connect, - OnHostMsgConnect) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Close, - OnHostMsgClose) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_SendText, - OnHostMsgSendText) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_SendBinary, - OnHostMsgSendBinary) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Fail, - OnHostMsgFail) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Connect, + OnHostMsgConnect) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Close, + OnHostMsgClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_SendText, + OnHostMsgSendText) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_SendBinary, + OnHostMsgSendBinary) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Fail, OnHostMsgFail) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -106,9 +103,7 @@ void PepperWebSocketHost::didConnect() { connecting_ = false; connect_reply_.params.set_result(PP_OK); host()->SendReply(connect_reply_, - PpapiPluginMsg_WebSocket_ConnectReply( - url_, - protocol)); + PpapiPluginMsg_WebSocket_ConnectReply(url_, protocol)); } void PepperWebSocketHost::didReceiveMessage(const blink::WebString& message) { @@ -118,9 +113,8 @@ void PepperWebSocketHost::didReceiveMessage(const blink::WebString& message) { // Send an IPC to transport received data. std::string string_message = message.utf8(); - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_WebSocket_ReceiveTextReply( - string_message)); + host()->SendUnsolicitedReply( + pp_resource(), PpapiPluginMsg_WebSocket_ReceiveTextReply(string_message)); } void PepperWebSocketHost::didReceiveArrayBuffer( @@ -132,9 +126,9 @@ void PepperWebSocketHost::didReceiveArrayBuffer( // Send an IPC to transport received data. uint8_t* data = static_cast<uint8_t*>(binaryData.data()); std::vector<uint8_t> array_message(data, data + binaryData.byteLength()); - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_WebSocket_ReceiveBinaryReply( - array_message)); + host()->SendUnsolicitedReply( + pp_resource(), + PpapiPluginMsg_WebSocket_ReceiveBinaryReply(array_message)); } void PepperWebSocketHost::didReceiveMessageError() { @@ -152,18 +146,18 @@ void PepperWebSocketHost::didReceiveMessageError() { void PepperWebSocketHost::didUpdateBufferedAmount( unsigned long buffered_amount) { // Send an IPC to update buffered amount. - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_WebSocket_BufferedAmountReply( - buffered_amount)); + host()->SendUnsolicitedReply( + pp_resource(), + PpapiPluginMsg_WebSocket_BufferedAmountReply(buffered_amount)); } void PepperWebSocketHost::didStartClosingHandshake() { accepting_close_ = true; // Send an IPC to notice that server starts closing handshake. - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_WebSocket_StateReply( - PP_WEBSOCKETREADYSTATE_CLOSING)); + host()->SendUnsolicitedReply( + pp_resource(), + PpapiPluginMsg_WebSocket_StateReply(PP_WEBSOCKETREADYSTATE_CLOSING)); } void PepperWebSocketHost::didClose(unsigned long unhandled_buffered_amount, @@ -179,27 +173,23 @@ void PepperWebSocketHost::didClose(unsigned long unhandled_buffered_amount, } // Set close_was_clean_. - bool was_clean = - (initiating_close_ || accepting_close_) && - !unhandled_buffered_amount && - status == WebSocketClient::ClosingHandshakeComplete; + bool was_clean = (initiating_close_ || accepting_close_) && + !unhandled_buffered_amount && + status == WebSocketClient::ClosingHandshakeComplete; if (initiating_close_) { initiating_close_ = false; close_reply_.params.set_result(PP_OK); - host()->SendReply(close_reply_, PpapiPluginMsg_WebSocket_CloseReply( - unhandled_buffered_amount, - was_clean, - code, - reason.utf8())); + host()->SendReply( + close_reply_, + PpapiPluginMsg_WebSocket_CloseReply( + unhandled_buffered_amount, was_clean, code, reason.utf8())); } else { accepting_close_ = false; - host()->SendUnsolicitedReply(pp_resource(), - PpapiPluginMsg_WebSocket_ClosedReply( - unhandled_buffered_amount, - was_clean, - code, - reason.utf8())); + host()->SendUnsolicitedReply( + pp_resource(), + PpapiPluginMsg_WebSocket_ClosedReply( + unhandled_buffered_amount, was_clean, code, reason.utf8())); } // Disconnect. @@ -232,8 +222,8 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( // Check containing characters. for (std::string::const_iterator string_it = vector_it->begin(); - string_it != vector_it->end(); - ++string_it) { + string_it != vector_it->end(); + ++string_it) { uint8_t character = *string_it; // WebSocket specification says "(Subprotocol string must consist of) // characters in the range U+0021 to U+007E not including separator @@ -241,12 +231,13 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( const uint8_t minimumProtocolCharacter = '!'; // U+0021. const uint8_t maximumProtocolCharacter = '~'; // U+007E. if (character < minimumProtocolCharacter || - character > maximumProtocolCharacter || - character == '"' || character == '(' || character == ')' || - character == ',' || character == '/' || + character > maximumProtocolCharacter || character == '"' || + character == '(' || character == ')' || character == ',' || + character == '/' || (character >= ':' && character <= '@') || // U+003A - U+0040 (character >= '[' && character <= ']') || // U+005B - u+005D - character == '{' || character == '}') + character == '{' || + character == '}') return PP_ERROR_BADARGUMENT; } // Join protocols with the comma separator. @@ -289,7 +280,7 @@ int32_t PepperWebSocketHost::OnHostMsgClose( initiating_close_ = true; blink::WebSocket::CloseEventCode event_code = - static_cast<blink::WebSocket::CloseEventCode>(code); + static_cast<blink::WebSocket::CloseEventCode>(code); if (code == PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) { // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED and CloseEventCodeNotSpecified are // assigned to different values. A conversion is needed if diff --git a/content/renderer/pepper/pepper_websocket_host.h b/content/renderer/pepper/pepper_websocket_host.h index 3447fcf..091b3e1 100644 --- a/content/renderer/pepper/pepper_websocket_host.h +++ b/content/renderer/pepper/pepper_websocket_host.h @@ -49,6 +49,7 @@ class CONTENT_EXPORT PepperWebSocketHost ClosingHandshakeCompletionStatus status, unsigned short code, const blink::WebString& reason); + private: // IPC message handlers. int32_t OnHostMsgConnect(ppapi::host::HostMessageContext* context, diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index a460515..7b8e65c 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -187,9 +187,7 @@ void ReleaseResource(PP_Resource resource) { PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource); } -PP_Time GetTime() { - return TimeToPPTime(base::Time::Now()); -} +PP_Time GetTime() { return TimeToPPTime(base::Time::Now()); } PP_TimeTicks GetTickTime() { return TimeTicksToPPTimeTicks(base::TimeTicks::Now()); @@ -207,18 +205,14 @@ void CallOnMainThread(int delay_in_msec, } PP_Bool IsMainThread() { - return BoolToPPBool(PpapiGlobals::Get()-> - GetMainThreadMessageLoop()->BelongsToCurrentThread()); + return BoolToPPBool(PpapiGlobals::Get() + ->GetMainThreadMessageLoop() + ->BelongsToCurrentThread()); } -const PPB_Core core_interface = { - &AddRefResource, - &ReleaseResource, - &GetTime, - &GetTickTime, - &CallOnMainThread, - &IsMainThread -}; +const PPB_Core core_interface = {&AddRefResource, &ReleaseResource, + &GetTime, &GetTickTime, + &CallOnMainThread, &IsMainThread}; // PPB_Testing ----------------------------------------------------------------- @@ -246,9 +240,7 @@ uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { instance_id); } -PP_Bool IsOutOfProcess() { - return PP_FALSE; -} +PP_Bool IsOutOfProcess() { return PP_FALSE; } void SimulateInputEvent(PP_Instance instance, PP_Resource input_event) { PepperPluginInstanceImpl* plugin_instance = @@ -288,16 +280,11 @@ void SetMinimumArrayBufferSizeForShmem(PP_Instance /*instance*/, } const PPB_Testing_Private testing_interface = { - &ReadImageData, - &RunMessageLoop, - &QuitMessageLoop, - &GetLiveObjectsForInstance, - &IsOutOfProcess, - &SimulateInputEvent, - &GetDocumentURL, - &GetLiveVars, - &SetMinimumArrayBufferSizeForShmem -}; + &ReadImageData, &RunMessageLoop, + &QuitMessageLoop, &GetLiveObjectsForInstance, + &IsOutOfProcess, &SimulateInputEvent, + &GetDocumentURL, &GetLiveVars, + &SetMinimumArrayBufferSizeForShmem}; // GetInterface ---------------------------------------------------------------- @@ -308,27 +295,27 @@ const void* InternalGetInterface(const char* name) { if (custom_interface) return custom_interface; - // TODO(brettw) put these in a hash map for better performance. - #define PROXIED_IFACE(iface_str, iface_struct) \ - if (strcmp(name, iface_str) == 0) \ - return ppapi::thunk::Get##iface_struct##_Thunk(); +// TODO(brettw) put these in a hash map for better performance. +#define PROXIED_IFACE(iface_str, iface_struct) \ + if (strcmp(name, iface_str) == 0) \ + return ppapi::thunk::Get##iface_struct##_Thunk(); - #include "ppapi/thunk/interfaces_ppb_private.h" - #include "ppapi/thunk/interfaces_ppb_private_flash.h" - #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" - #include "ppapi/thunk/interfaces_ppb_public_dev.h" - #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" - #include "ppapi/thunk/interfaces_ppb_public_stable.h" +#include "ppapi/thunk/interfaces_ppb_private.h" +#include "ppapi/thunk/interfaces_ppb_private_flash.h" +#include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" +#include "ppapi/thunk/interfaces_ppb_public_dev.h" +#include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" +#include "ppapi/thunk/interfaces_ppb_public_stable.h" - #undef PROXIED_IFACE +#undef PROXIED_IFACE - #define LEGACY_IFACE(iface_str, function_name) \ - if (strcmp(name, iface_str) == 0) \ - return function_name; +#define LEGACY_IFACE(iface_str, function_name) \ + if (strcmp(name, iface_str) == 0) \ + return function_name; - #include "ppapi/thunk/interfaces_legacy.h" +#include "ppapi/thunk/interfaces_legacy.h" - #undef LEGACY_IFACE +#undef LEGACY_IFACE // Only support the testing interface when the command line switch is // specified. This allows us to prevent people from (ab)using this interface @@ -350,9 +337,8 @@ const void* GetInterface(const char* name) { // Gets the PPAPI entry points from the given library and places them into the // given structure. Returns true on success. -bool LoadEntryPointsFromLibrary( - const base::NativeLibrary& library, - PepperPluginInfo::EntryPoints* entry_points) { +bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, + PepperPluginInfo::EntryPoints* entry_points) { entry_points->get_interface = reinterpret_cast<PepperPluginInfo::GetInterfaceFunc>( base::GetFunctionPointerFromNativeLibrary(library, @@ -389,9 +375,9 @@ void CreateHostForInProcessModule(RenderFrameImpl* render_frame, PepperPluginRegistry::GetInstance()->GetInfoForPlugin(webplugin_info); DCHECK(!info->is_out_of_process); - ppapi::PpapiPermissions perms( - PepperPluginRegistry::GetInstance()->GetInfoForPlugin( - webplugin_info)->permissions); + ppapi::PpapiPermissions perms(PepperPluginRegistry::GetInstance() + ->GetInfoForPlugin(webplugin_info) + ->permissions); RendererPpapiHostImpl* host_impl = RendererPpapiHostImpl::CreateOnModuleForInProcess(module, perms); render_frame->PepperPluginCreated(host_impl); @@ -498,13 +484,11 @@ void PluginModule::InitAsProxied( } scoped_refptr<PluginModule> - PluginModule::CreateModuleForExternalPluginInstance() { +PluginModule::CreateModuleForExternalPluginInstance() { // Create a new module, but don't set the lifetime delegate. This isn't a // plugin in the usual sense, so it isn't tracked by the browser. scoped_refptr<PluginModule> external_plugin_module( - new PluginModule(name_, - path_, - permissions_)); + new PluginModule(name_, path_, permissions_)); return external_plugin_module; } @@ -522,9 +506,7 @@ PP_ExternalPluginResult PluginModule::InitAsProxiedExternalPlugin( return instance->ResetAsProxied(this); } -bool PluginModule::IsProxied() const { - return !!host_dispatcher_wrapper_; -} +bool PluginModule::IsProxied() const { return !!host_dispatcher_wrapper_; } base::ProcessId PluginModule::GetPeerProcessId() { if (host_dispatcher_wrapper_) @@ -539,9 +521,7 @@ int PluginModule::GetPluginChildId() { } // static -const PPB_Core* PluginModule::GetCore() { - return &core_interface; -} +const PPB_Core* PluginModule::GetCore() { return &core_interface; } // static bool PluginModule::SupportsInterface(const char* name) { @@ -600,7 +580,8 @@ void PluginModule::PluginCrashed() { // Notify all instances that they crashed. for (PluginInstanceSet::iterator i = instances_.begin(); - i != instances_.end(); ++i) + i != instances_.end(); + ++i) (*i)->InstanceCrashed(); PepperPluginRegistry::GetInstance()->PluginModuleDead(this); @@ -623,9 +604,7 @@ void PluginModule::SetBroker(PepperBroker* broker) { broker_ = broker; } -PepperBroker* PluginModule::GetBroker() { - return broker_; -} +PepperBroker* PluginModule::GetBroker() { return broker_; } RendererPpapiHostImpl* PluginModule::CreateOutOfProcessModule( RenderFrameImpl* render_frame, @@ -637,12 +616,8 @@ RendererPpapiHostImpl* PluginModule::CreateOutOfProcessModule( bool is_external) { scoped_refptr<PepperHungPluginFilter> hung_filter(new PepperHungPluginFilter( path, render_frame->GetRoutingID(), plugin_child_id)); - scoped_ptr<HostDispatcherWrapper> dispatcher( - new HostDispatcherWrapper(this, - peer_pid, - plugin_child_id, - permissions, - is_external)); + scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper( + this, peer_pid, plugin_child_id, permissions, is_external)); if (!dispatcher->Init( channel_handle, &GetInterface, diff --git a/content/renderer/pepper/plugin_module.h b/content/renderer/pepper/plugin_module.h index ad9463c..dd25ecf 100644 --- a/content/renderer/pepper/plugin_module.h +++ b/content/renderer/pepper/plugin_module.h @@ -58,9 +58,8 @@ struct WebPluginInfo; // // Note: to get from a PP_Instance to a PepperPluginInstance*, use the // ResourceTracker. -class CONTENT_EXPORT PluginModule : - public base::RefCounted<PluginModule>, - public base::SupportsWeakPtr<PluginModule> { +class CONTENT_EXPORT PluginModule : public base::RefCounted<PluginModule>, + public base::SupportsWeakPtr<PluginModule> { public: typedef std::set<PepperPluginInstanceImpl*> PluginInstanceSet; @@ -138,10 +137,9 @@ class CONTENT_EXPORT PluginModule : const base::FilePath& path() const { return path_; } const ppapi::PpapiPermissions& permissions() const { return permissions_; } - PepperPluginInstanceImpl* CreateInstance( - RenderFrameImpl* render_frame, - blink::WebPluginContainer* container, - const GURL& plugin_url); + PepperPluginInstanceImpl* CreateInstance(RenderFrameImpl* render_frame, + blink::WebPluginContainer* container, + const GURL& plugin_url); // Returns "some" plugin instance associated with this module. This is not // guaranteed to be any one in particular. This is normally used to execute @@ -178,8 +176,7 @@ class CONTENT_EXPORT PluginModule : // it exists to validate the ID. If the callback has not been set (such as // for in-process plugins), the Reserve function will assume that the ID is // usable and will return true. - void SetReserveInstanceIDCallback( - PP_Bool (*reserve)(PP_Module, PP_Instance)); + void SetReserveInstanceIDCallback(PP_Bool (*reserve)(PP_Module, PP_Instance)); bool ReserveInstanceID(PP_Instance instance); // These should only be called from the main thread. diff --git a/content/renderer/pepper/plugin_object.cc b/content/renderer/pepper/plugin_object.cc index 0ec50e5..62a9365 100644 --- a/content/renderer/pepper/plugin_object.cc +++ b/content/renderer/pepper/plugin_object.cc @@ -49,8 +49,7 @@ void WrapperClass_Deallocate(NPObject* np_object) { delete plugin_object; } -void WrapperClass_Invalidate(NPObject* object) { -} +void WrapperClass_Invalidate(NPObject* object) {} bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) { NPObjectAccessorWithIdentifier accessor(object, method_name, false); @@ -60,14 +59,17 @@ bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) { PPResultAndExceptionToNPResult result_converter( accessor.object()->GetNPObject(), NULL); bool rv = accessor.object()->ppp_class()->HasMethod( - accessor.object()->ppp_class_data(), accessor.identifier(), + accessor.object()->ppp_class_data(), + accessor.identifier(), result_converter.exception()); result_converter.CheckExceptionForNoResult(); return rv; } -bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name, - const NPVariant* argv, uint32_t argc, +bool WrapperClass_Invoke(NPObject* object, + NPIdentifier method_name, + const NPVariant* argv, + uint32_t argc, NPVariant* result) { NPObjectAccessorWithIdentifier accessor(object, method_name, false); if (!accessor.is_valid()) @@ -75,8 +77,7 @@ bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name, PPResultAndExceptionToNPResult result_converter( accessor.object()->GetNPObject(), result); - PPVarArrayFromNPVariantArray args(accessor.object()->instance(), - argc, argv); + PPVarArrayFromNPVariantArray args(accessor.object()->instance(), argc, argv); // For the OOP plugin case we need to grab a reference on the plugin module // object to ensure that it is not destroyed courtsey an incoming @@ -84,13 +85,18 @@ bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name, // dispatcher. scoped_refptr<PluginModule> ref(accessor.object()->instance()->module()); - return result_converter.SetResult(accessor.object()->ppp_class()->Call( - accessor.object()->ppp_class_data(), accessor.identifier(), - argc, args.array(), result_converter.exception())); + return result_converter.SetResult( + accessor.object()->ppp_class()->Call(accessor.object()->ppp_class_data(), + accessor.identifier(), + argc, + args.array(), + result_converter.exception())); } -bool WrapperClass_InvokeDefault(NPObject* np_object, const NPVariant* argv, - uint32_t argc, NPVariant* result) { +bool WrapperClass_InvokeDefault(NPObject* np_object, + const NPVariant* argv, + uint32_t argc, + NPVariant* result) { PluginObject* obj = PluginObject::FromNPObject(np_object); if (!obj) return false; @@ -104,9 +110,12 @@ bool WrapperClass_InvokeDefault(NPObject* np_object, const NPVariant* argv, // dispatcher. scoped_refptr<PluginModule> ref(obj->instance()->module()); - result_converter.SetResult(obj->ppp_class()->Call( - obj->ppp_class_data(), PP_MakeUndefined(), argc, args.array(), - result_converter.exception())); + result_converter.SetResult( + obj->ppp_class()->Call(obj->ppp_class_data(), + PP_MakeUndefined(), + argc, + args.array(), + result_converter.exception())); return result_converter.success(); } @@ -118,13 +127,15 @@ bool WrapperClass_HasProperty(NPObject* object, NPIdentifier property_name) { PPResultAndExceptionToNPResult result_converter( accessor.object()->GetNPObject(), NULL); bool rv = accessor.object()->ppp_class()->HasProperty( - accessor.object()->ppp_class_data(), accessor.identifier(), + accessor.object()->ppp_class_data(), + accessor.identifier(), result_converter.exception()); result_converter.CheckExceptionForNoResult(); return rv; } -bool WrapperClass_GetProperty(NPObject* object, NPIdentifier property_name, +bool WrapperClass_GetProperty(NPObject* object, + NPIdentifier property_name, NPVariant* result) { NPObjectAccessorWithIdentifier accessor(object, property_name, true); if (!accessor.is_valid()) @@ -133,11 +144,13 @@ bool WrapperClass_GetProperty(NPObject* object, NPIdentifier property_name, PPResultAndExceptionToNPResult result_converter( accessor.object()->GetNPObject(), result); return result_converter.SetResult(accessor.object()->ppp_class()->GetProperty( - accessor.object()->ppp_class_data(), accessor.identifier(), + accessor.object()->ppp_class_data(), + accessor.identifier(), result_converter.exception())); } -bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name, +bool WrapperClass_SetProperty(NPObject* object, + NPIdentifier property_name, const NPVariant* value) { NPObjectAccessorWithIdentifier accessor(object, property_name, true); if (!accessor.is_valid()) @@ -147,7 +160,9 @@ bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name, accessor.object()->GetNPObject(), NULL); PP_Var value_var = NPVariantToPPVar(accessor.object()->instance(), value); accessor.object()->ppp_class()->SetProperty( - accessor.object()->ppp_class_data(), accessor.identifier(), value_var, + accessor.object()->ppp_class_data(), + accessor.identifier(), + value_var, result_converter.exception()); PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(value_var); return result_converter.CheckExceptionForNoResult(); @@ -161,12 +176,14 @@ bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) { PPResultAndExceptionToNPResult result_converter( accessor.object()->GetNPObject(), NULL); accessor.object()->ppp_class()->RemoveProperty( - accessor.object()->ppp_class_data(), accessor.identifier(), + accessor.object()->ppp_class_data(), + accessor.identifier(), result_converter.exception()); return result_converter.CheckExceptionForNoResult(); } -bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, +bool WrapperClass_Enumerate(NPObject* object, + NPIdentifier** values, uint32_t* count) { *values = NULL; *count = 0; @@ -178,7 +195,8 @@ bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, PP_Var* properties = NULL; // Must be freed! PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), NULL); obj->ppp_class()->GetAllPropertyNames(obj->ppp_class_data(), - &property_count, &properties, + &property_count, + &properties, result_converter.exception()); // Convert the array of PP_Var to an array of NPIdentifiers. If any @@ -221,8 +239,10 @@ bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, return result_converter.success(); } -bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, - uint32_t argc, NPVariant* result) { +bool WrapperClass_Construct(NPObject* object, + const NPVariant* argv, + uint32_t argc, + NPVariant* result) { PluginObject* obj = PluginObject::FromNPObject(object); if (!obj) return false; @@ -230,25 +250,17 @@ bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, PPVarArrayFromNPVariantArray args(obj->instance(), argc, argv); PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result); return result_converter.SetResult(obj->ppp_class()->Construct( - obj->ppp_class_data(), argc, args.array(), - result_converter.exception())); + obj->ppp_class_data(), argc, args.array(), result_converter.exception())); } const NPClass wrapper_class = { - NP_CLASS_STRUCT_VERSION, - WrapperClass_Allocate, - WrapperClass_Deallocate, - WrapperClass_Invalidate, - WrapperClass_HasMethod, - WrapperClass_Invoke, - WrapperClass_InvokeDefault, - WrapperClass_HasProperty, - WrapperClass_GetProperty, - WrapperClass_SetProperty, - WrapperClass_RemoveProperty, - WrapperClass_Enumerate, - WrapperClass_Construct -}; + NP_CLASS_STRUCT_VERSION, WrapperClass_Allocate, + WrapperClass_Deallocate, WrapperClass_Invalidate, + WrapperClass_HasMethod, WrapperClass_Invoke, + WrapperClass_InvokeDefault, WrapperClass_HasProperty, + WrapperClass_GetProperty, WrapperClass_SetProperty, + WrapperClass_RemoveProperty, WrapperClass_Enumerate, + WrapperClass_Construct}; } // namespace @@ -293,9 +305,9 @@ PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance, // This will internally end up calling our AllocateObjectWrapper via the // WrapperClass_Allocated function which will have created an object wrapper // appropriate for this class (derived from NPObject). - NPObjectWrapper* wrapper = static_cast<NPObjectWrapper*>( - WebBindings::createObject(instance->instanceNPP(), - const_cast<NPClass*>(&wrapper_class))); + NPObjectWrapper* wrapper = + static_cast<NPObjectWrapper*>(WebBindings::createObject( + instance->instanceNPP(), const_cast<NPClass*>(&wrapper_class))); // This object will register itself both with the NPObject and with the // PluginModule. The NPObject will normally handle its lifetime, and it @@ -316,9 +328,7 @@ PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance, return obj_var; } -NPObject* PluginObject::GetNPObject() const { - return object_wrapper_; -} +NPObject* PluginObject::GetNPObject() const { return object_wrapper_; } // static bool PluginObject::IsInstanceOf(NPObject* np_object, @@ -353,4 +363,3 @@ NPObject* PluginObject::AllocateObjectWrapper() { } } // namespace content - diff --git a/content/renderer/pepper/plugin_object.h b/content/renderer/pepper/plugin_object.h index 362979a..62ffd2e 100644 --- a/content/renderer/pepper/plugin_object.h +++ b/content/renderer/pepper/plugin_object.h @@ -35,7 +35,9 @@ class PluginObject { PepperPluginInstanceImpl* instance() const { return instance_; } const PPP_Class_Deprecated* ppp_class() { return ppp_class_; } - void* ppp_class_data() { return ppp_class_data_; }; + void* ppp_class_data() { + return ppp_class_data_; + }; NPObject* GetNPObject() const; diff --git a/content/renderer/pepper/ppb_audio_impl.cc b/content/renderer/pepper/ppb_audio_impl.cc index 864c61d..652c697 100644 --- a/content/renderer/pepper/ppb_audio_impl.cc +++ b/content/renderer/pepper/ppb_audio_impl.cc @@ -30,9 +30,7 @@ namespace content { // PPB_Audio_Impl -------------------------------------------------------------- PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) - : Resource(ppapi::OBJECT_IS_IMPL, instance), - audio_(NULL) { -} + : Resource(ppapi::OBJECT_IS_IMPL, instance), audio_(NULL) {} PPB_Audio_Impl::~PPB_Audio_Impl() { // Calling ShutDown() makes sure StreamCreated cannot be called anymore and @@ -46,9 +44,7 @@ PPB_Audio_Impl::~PPB_Audio_Impl() { } } -PPB_Audio_API* PPB_Audio_Impl::AsPPB_Audio_API() { - return this; -} +PPB_Audio_API* PPB_Audio_Impl::AsPPB_Audio_API() { return this; } PP_Resource PPB_Audio_Impl::GetCurrentConfig() { // AddRef on behalf of caller, while keeping a ref for ourselves. @@ -76,9 +72,8 @@ PP_Bool PPB_Audio_Impl::StopPlayback() { return PP_TRUE; } -int32_t PPB_Audio_Impl::Open( - PP_Resource config, - scoped_refptr<TrackedCallback> create_callback) { +int32_t PPB_Audio_Impl::Open(PP_Resource config, + scoped_refptr<TrackedCallback> create_callback) { // Validate the config and keep a reference to it. EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); if (enter.failed()) @@ -113,8 +108,7 @@ int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) { return GetSyncSocketImpl(sync_socket); } -int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, - uint32_t* shm_size) { +int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { return GetSharedMemoryImpl(shm_handle, shm_size); } @@ -123,8 +117,11 @@ void PPB_Audio_Impl::OnSetStreamInfo( size_t shared_memory_size, base::SyncSocket::Handle socket_handle) { EnterResourceNoLock<PPB_AudioConfig_API> enter(config_, true); - SetStreamInfo(pp_instance(), shared_memory_handle, shared_memory_size, - socket_handle, enter.object()->GetSampleRate(), + SetStreamInfo(pp_instance(), + shared_memory_handle, + shared_memory_size, + socket_handle, + enter.object()->GetSampleRate(), enter.object()->GetSampleFrameCount()); } diff --git a/content/renderer/pepper/ppb_audio_impl.h b/content/renderer/pepper/ppb_audio_impl.h index 708524b..ecd49eb 100644 --- a/content/renderer/pepper/ppb_audio_impl.h +++ b/content/renderer/pepper/ppb_audio_impl.h @@ -39,9 +39,9 @@ class PPB_Audio_Impl : public ppapi::Resource, virtual PP_Resource GetCurrentConfig() OVERRIDE; virtual PP_Bool StartPlayback() OVERRIDE; virtual PP_Bool StopPlayback() OVERRIDE; - virtual int32_t Open( - PP_Resource config_id, - scoped_refptr<ppapi::TrackedCallback> create_callback) OVERRIDE; + virtual int32_t Open(PP_Resource config_id, + scoped_refptr<ppapi::TrackedCallback> create_callback) + OVERRIDE; virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; diff --git a/content/renderer/pepper/ppb_broker_impl.cc b/content/renderer/pepper/ppb_broker_impl.cc index bec93e0..bc2cbfa 100644 --- a/content/renderer/pepper/ppb_broker_impl.cc +++ b/content/renderer/pepper/ppb_broker_impl.cc @@ -47,9 +47,7 @@ PPB_Broker_Impl::~PPB_Broker_Impl() { ChildThread::current()->GetRouter()->RemoveRoute(routing_id_); } -PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { - return this; -} +PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { return this; } int32_t PPB_Broker_Impl::Connect( scoped_refptr<TrackedCallback> connect_callback) { @@ -78,8 +76,8 @@ int32_t PPB_Broker_Impl::Connect( broker_ = new PepperBroker(module); // Have the browser start the broker process for us. - RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPpapiBroker( - routing_id_, broker_path)); + RenderThreadImpl::current()->Send( + new ViewHostMsg_OpenChannelToPpapiBroker(routing_id_, broker_path)); } RenderThreadImpl::current()->Send( @@ -111,8 +109,7 @@ GURL PPB_Broker_Impl::GetDocumentUrl() { // Transfers ownership of the handle to the plugin. void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { - DCHECK(pipe_handle_ == - PlatformFileToInt(base::kInvalidPlatformFileValue)); + DCHECK(pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue)); DCHECK(result == PP_OK || handle == PlatformFileToInt(base::kInvalidPlatformFileValue)); @@ -127,11 +124,11 @@ void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { bool PPB_Broker_Impl::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Broker_Impl, message) - IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, - OnPpapiBrokerChannelCreated) - IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, - OnPpapiBrokerPermissionResult) - IPC_MESSAGE_UNHANDLED(handled = false) + IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, + OnPpapiBrokerChannelCreated) + IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, + OnPpapiBrokerPermissionResult) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } diff --git a/content/renderer/pepper/ppb_buffer_impl.cc b/content/renderer/pepper/ppb_buffer_impl.cc index 4b806b9..453e716 100644 --- a/content/renderer/pepper/ppb_buffer_impl.cc +++ b/content/renderer/pepper/ppb_buffer_impl.cc @@ -20,13 +20,9 @@ using ppapi::thunk::PPB_Buffer_API; namespace content { PPB_Buffer_Impl::PPB_Buffer_Impl(PP_Instance instance) - : Resource(ppapi::OBJECT_IS_IMPL, instance), - size_(0), - map_count_(0) { -} + : Resource(ppapi::OBJECT_IS_IMPL, instance), size_(0), map_count_(0) {} -PPB_Buffer_Impl::~PPB_Buffer_Impl() { -} +PPB_Buffer_Impl::~PPB_Buffer_Impl() {} // static PP_Resource PPB_Buffer_Impl::Create(PP_Instance instance, uint32_t size) { @@ -46,13 +42,9 @@ scoped_refptr<PPB_Buffer_Impl> PPB_Buffer_Impl::CreateResource( return buffer; } -PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { - return this; -} +PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { return this; } -PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() { - return this; -} +PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() { return this; } bool PPB_Buffer_Impl::Init(uint32_t size) { if (size == 0) @@ -89,8 +81,7 @@ int32_t PPB_Buffer_Impl::GetSharedMemory(int* shm_handle) { #if defined(OS_POSIX) *shm_handle = shared_memory_->handle().fd; #elif defined(OS_WIN) - *shm_handle = reinterpret_cast<int>( - shared_memory_->handle()); + *shm_handle = reinterpret_cast<int>(shared_memory_->handle()); #else #error "Platform not supported." #endif diff --git a/content/renderer/pepper/ppb_flash_message_loop_impl.cc b/content/renderer/pepper/ppb_flash_message_loop_impl.cc index ff2abc4..b64abe6 100644 --- a/content/renderer/pepper/ppb_flash_message_loop_impl.cc +++ b/content/renderer/pepper/ppb_flash_message_loop_impl.cc @@ -15,8 +15,7 @@ namespace content { class PPB_Flash_MessageLoop_Impl::State : public base::RefCounted<PPB_Flash_MessageLoop_Impl::State> { public: - State() : result_(PP_OK), run_called_(false), quit_called_(false) { - } + State() : result_(PP_OK), run_called_(false), quit_called_(false) {} int32_t result() const { return result_; } void set_result(int32_t result) { result_ = result; } @@ -43,9 +42,7 @@ class PPB_Flash_MessageLoop_Impl::State }; PPB_Flash_MessageLoop_Impl::PPB_Flash_MessageLoop_Impl(PP_Instance instance) - : Resource(ppapi::OBJECT_IS_IMPL, instance), - state_(new State()) { -} + : Resource(ppapi::OBJECT_IS_IMPL, instance), state_(new State()) {} PPB_Flash_MessageLoop_Impl::~PPB_Flash_MessageLoop_Impl() { // It is a no-op if either Run() hasn't been called or Quit() has been called @@ -59,7 +56,7 @@ PP_Resource PPB_Flash_MessageLoop_Impl::Create(PP_Instance instance) { } PPB_Flash_MessageLoop_API* - PPB_Flash_MessageLoop_Impl::AsPPB_Flash_MessageLoop_API() { +PPB_Flash_MessageLoop_Impl::AsPPB_Flash_MessageLoop_API() { return this; } @@ -72,9 +69,7 @@ void PPB_Flash_MessageLoop_Impl::RunFromHostProxy( InternalRun(callback); } -void PPB_Flash_MessageLoop_Impl::Quit() { - InternalQuit(PP_OK); -} +void PPB_Flash_MessageLoop_Impl::Quit() { InternalQuit(PP_OK); } int32_t PPB_Flash_MessageLoop_Impl::InternalRun( const RunFromHostProxyCallback& callback) { diff --git a/content/renderer/pepper/ppb_flash_message_loop_impl.h b/content/renderer/pepper/ppb_flash_message_loop_impl.h index 981a7da..b26d4ce 100644 --- a/content/renderer/pepper/ppb_flash_message_loop_impl.h +++ b/content/renderer/pepper/ppb_flash_message_loop_impl.h @@ -20,14 +20,14 @@ class PPB_Flash_MessageLoop_Impl static PP_Resource Create(PP_Instance instance); // Resource. - virtual ppapi::thunk::PPB_Flash_MessageLoop_API* - AsPPB_Flash_MessageLoop_API() OVERRIDE; + virtual ppapi::thunk::PPB_Flash_MessageLoop_API* AsPPB_Flash_MessageLoop_API() + OVERRIDE; // PPB_Flash_MessageLoop_API implementation. virtual int32_t Run() OVERRIDE; virtual void Quit() OVERRIDE; - virtual void RunFromHostProxy( - const RunFromHostProxyCallback& callback) OVERRIDE; + virtual void RunFromHostProxy(const RunFromHostProxyCallback& callback) + OVERRIDE; private: class State; diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc index 3ad09d4..1460bf0 100644 --- a/content/renderer/pepper/ppb_graphics_3d_impl.cc +++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc @@ -44,12 +44,9 @@ PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) : PPB_Graphics3D_Shared(instance), bound_to_instance_(false), commit_pending_(false), - weak_ptr_factory_(this) { -} + weak_ptr_factory_(this) {} -PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { - DestroyGLES2Impl(); -} +PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { DestroyGLES2Impl(); } // static PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance, @@ -135,9 +132,7 @@ bool PPB_Graphics3D_Impl::BindToInstance(bool bind) { return true; } -bool PPB_Graphics3D_Impl::IsOpaque() { - return platform_context_->IsOpaque(); -} +bool PPB_Graphics3D_Impl::IsOpaque() { return platform_context_->IsOpaque(); } void PPB_Graphics3D_Impl::ViewInitiatedPaint() { commit_pending_ = false; @@ -146,8 +141,7 @@ void PPB_Graphics3D_Impl::ViewInitiatedPaint() { SwapBuffersACK(PP_OK); } -void PPB_Graphics3D_Impl::ViewFlushedPaint() { -} +void PPB_Graphics3D_Impl::ViewFlushedPaint() {} gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { return platform_context_->GetCommandBuffer(); @@ -184,7 +178,6 @@ int32 PPB_Graphics3D_Impl::DoSwapBuffers() { weak_ptr_factory_.GetWeakPtr())); } - return PP_OK_COMPLETIONPENDING; } @@ -203,8 +196,7 @@ bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context, static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl(); } - return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, - share_gles2); + return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2); } bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, @@ -214,8 +206,9 @@ bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, if (!plugin_instance) return false; - const WebPreferences& prefs = static_cast<RenderViewImpl*>(plugin_instance-> - GetRenderView())->webkit_preferences(); + const WebPreferences& prefs = + static_cast<RenderViewImpl*>(plugin_instance->GetRenderView()) + ->webkit_preferences(); // 3D access might be disabled or blacklisted. if (!prefs.pepper_3d_enabled) return false; @@ -239,18 +232,15 @@ bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, if (!platform_context_->Init(attrib_list, share_platform_context)) return false; - platform_context_->SetContextLostCallback( - base::Bind(&PPB_Graphics3D_Impl::OnContextLost, - weak_ptr_factory_.GetWeakPtr())); + platform_context_->SetContextLostCallback(base::Bind( + &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); - platform_context_->SetOnConsoleMessageCallback( - base::Bind(&PPB_Graphics3D_Impl::OnConsoleMessage, - weak_ptr_factory_.GetWeakPtr())); + platform_context_->SetOnConsoleMessageCallback(base::Bind( + &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); return true; } -void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, - int id) { +void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) { if (!bound_to_instance_) return; WebPluginContainer* container = @@ -278,8 +268,8 @@ void PPB_Graphics3D_Impl::OnContextLost() { // Don't need to check for NULL from GetPluginInstance since when we're // bound, we know our instance is valid. if (bound_to_instance_) { - HostGlobals::Get()->GetInstance(pp_instance())->BindGraphics( - pp_instance(), 0); + HostGlobals::Get()->GetInstance(pp_instance())->BindGraphics(pp_instance(), + 0); } // Send context lost to plugin. This may have been caused by a PPAPI call, so @@ -304,10 +294,8 @@ void PPB_Graphics3D_Impl::SendContextLost() { // send the Graphics3DContextLost to the plugin; the instance may care about // that event even though this context has been destroyed. PP_Instance this_pp_instance = pp_instance(); - const PPP_Graphics3D* ppp_graphics_3d = - static_cast<const PPP_Graphics3D*>( - instance->module()->GetPluginInterface( - PPP_GRAPHICS_3D_INTERFACE)); + const PPP_Graphics3D* ppp_graphics_3d = static_cast<const PPP_Graphics3D*>( + instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); // We have to check *again* that the instance exists, because it could have // been deleted during GetPluginInterface(). Even the PluginModule could be // deleted, but in that case, the instance should also be gone, so the diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.h b/content/renderer/pepper/ppb_graphics_3d_impl.h index 97a9b9d..6594dce 100644 --- a/content/renderer/pepper/ppb_graphics_3d_impl.h +++ b/content/renderer/pepper/ppb_graphics_3d_impl.h @@ -59,10 +59,8 @@ class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { private: explicit PPB_Graphics3D_Impl(PP_Instance instance); - bool Init(PPB_Graphics3D_API* share_context, - const int32_t* attrib_list); - bool InitRaw(PPB_Graphics3D_API* share_context, - const int32_t* attrib_list); + bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); + bool InitRaw(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); // Notifications received from the GPU process. void OnSwapBuffers(); diff --git a/content/renderer/pepper/ppb_image_data_impl.cc b/content/renderer/pepper/ppb_image_data_impl.cc index 6abd8f5..086eee2 100644 --- a/content/renderer/pepper/ppb_image_data_impl.cc +++ b/content/renderer/pepper/ppb_image_data_impl.cc @@ -51,25 +51,24 @@ PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, case PPB_ImageData_Shared::SIMPLE: backend_.reset(new ImageDataSimpleBackend); return; - // No default: so that we get a compiler warning if any types are added. + // No default: so that we get a compiler warning if any types are added. } NOTREACHED(); } -PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, - ForTest) +PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, ForTest) : Resource(ppapi::OBJECT_IS_IMPL, instance), format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL), width_(0), height_(0) { - backend_.reset(new ImageDataPlatformBackend(false)); + backend_.reset(new ImageDataPlatformBackend(false)); } -PPB_ImageData_Impl::~PPB_ImageData_Impl() { -} +PPB_ImageData_Impl::~PPB_ImageData_Impl() {} bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, - int width, int height, + int width, + int height, bool init_to_zero) { // TODO(brettw) this should be called only on the main thread! if (!IsImageDataFormatSupported(format)) @@ -92,20 +91,16 @@ PP_Resource PPB_ImageData_Impl::Create(PP_Instance instance, PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) { - scoped_refptr<PPB_ImageData_Impl> - data(new PPB_ImageData_Impl(instance, type)); + scoped_refptr<PPB_ImageData_Impl> data( + new PPB_ImageData_Impl(instance, type)); if (!data->Init(format, size.width, size.height, !!init_to_zero)) return 0; return data->GetReference(); } -PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() { - return this; -} +PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() { return this; } -bool PPB_ImageData_Impl::IsMapped() const { - return backend_->IsMapped(); -} +bool PPB_ImageData_Impl::IsMapped() const { return backend_->IsMapped(); } TransportDIB* PPB_ImageData_Impl::GetTransportDIB() const { return backend_->GetTransportDIB(); @@ -119,13 +114,9 @@ PP_Bool PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) { return PP_TRUE; } -void* PPB_ImageData_Impl::Map() { - return backend_->Map(); -} +void* PPB_ImageData_Impl::Map() { return backend_->Map(); } -void PPB_ImageData_Impl::Unmap() { - backend_->Unmap(); -} +void PPB_ImageData_Impl::Unmap() { backend_->Unmap(); } int32_t PPB_ImageData_Impl::GetSharedMemory(int* handle, uint32_t* byte_count) { return backend_->GetSharedMemory(handle, byte_count); @@ -135,9 +126,7 @@ skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() { return backend_->GetPlatformCanvas(); } -SkCanvas* PPB_ImageData_Impl::GetCanvas() { - return backend_->GetCanvas(); -} +SkCanvas* PPB_ImageData_Impl::GetCanvas() { return backend_->GetCanvas(); } void PPB_ImageData_Impl::SetIsCandidateForReuse() { // Nothing to do since we don't support image data re-use in-process. @@ -150,10 +139,7 @@ const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const { // ImageDataPlatformBackend ---------------------------------------------------- ImageDataPlatformBackend::ImageDataPlatformBackend(bool is_browser_allocated) - : width_(0), - height_(0), - is_browser_allocated_(is_browser_allocated) { -} + : width_(0), height_(0), is_browser_allocated_(is_browser_allocated) {} // On POSIX, we have to tell the browser to free the transport DIB. ImageDataPlatformBackend::~ImageDataPlatformBackend() { @@ -169,7 +155,8 @@ ImageDataPlatformBackend::~ImageDataPlatformBackend() { bool ImageDataPlatformBackend::Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, - int width, int height, + int width, + int height, bool init_to_zero) { // TODO(brettw) use init_to_zero when we implement caching. width_ = width; @@ -186,9 +173,8 @@ bool ImageDataPlatformBackend::Init(PPB_ImageData_Impl* impl, // TransportDIB is cached in the browser, and is freed (in typical cases) by // the TransportDIB's destructor. TransportDIB::Handle dib_handle; - IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size, - true, - &dib_handle); + IPC::Message* msg = + new ViewHostMsg_AllocTransportDIB(buffer_size, true, &dib_handle); if (!RenderThreadImpl::current()->Send(msg)) return false; if (!TransportDIB::is_valid_handle(dib_handle)) @@ -254,9 +240,7 @@ skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { return mapped_canvas_.get(); } -SkCanvas* ImageDataPlatformBackend::GetCanvas() { - return mapped_canvas_.get(); -} +SkCanvas* ImageDataPlatformBackend::GetCanvas() { return mapped_canvas_.get(); } const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { if (!mapped_canvas_) @@ -266,31 +250,27 @@ const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { // ImageDataSimpleBackend ------------------------------------------------------ -ImageDataSimpleBackend::ImageDataSimpleBackend() - : map_count_(0) { -} +ImageDataSimpleBackend::ImageDataSimpleBackend() : map_count_(0) {} -ImageDataSimpleBackend::~ImageDataSimpleBackend() { -} +ImageDataSimpleBackend::~ImageDataSimpleBackend() {} bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, - int width, int height, + int width, + int height, bool init_to_zero) { - skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, - impl->width(), impl->height()); - shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer( - skia_bitmap_.getSize()).release()); + skia_bitmap_.setConfig( + SkBitmap::kARGB_8888_Config, impl->width(), impl->height()); + shared_memory_.reset( + RenderThread::Get() + ->HostAllocateSharedMemoryBuffer(skia_bitmap_.getSize()) + .release()); return !!shared_memory_.get(); } -bool ImageDataSimpleBackend::IsMapped() const { - return map_count_ > 0; -} +bool ImageDataSimpleBackend::IsMapped() const { return map_count_ > 0; } -TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { - return NULL; -} +TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { return NULL; } void* ImageDataSimpleBackend::Map() { DCHECK(shared_memory_.get()); diff --git a/content/renderer/pepper/ppb_image_data_impl.h b/content/renderer/pepper/ppb_image_data_impl.h index 49c399b..3ec7986 100644 --- a/content/renderer/pepper/ppb_image_data_impl.h +++ b/content/renderer/pepper/ppb_image_data_impl.h @@ -36,8 +36,11 @@ class CONTENT_EXPORT PPB_ImageData_Impl class Backend { public: virtual ~Backend() {}; - virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, - int width, int height, bool init_to_zero) = 0; + virtual bool Init(PPB_ImageData_Impl* impl, + PP_ImageDataFormat format, + int width, + int height, + bool init_to_zero) = 0; virtual bool IsMapped() const = 0; virtual TransportDIB* GetTransportDIB() const = 0; virtual void* Map() = 0; @@ -56,11 +59,11 @@ class CONTENT_EXPORT PPB_ImageData_Impl // Constructor used for unittests. The ImageData is always allocated locally. struct ForTest {}; - PPB_ImageData_Impl(PP_Instance instance, - ForTest); + PPB_ImageData_Impl(PP_Instance instance, ForTest); bool Init(PP_ImageDataFormat format, - int width, int height, + int width, + int height, bool init_to_zero); static PP_Resource Create(PP_Instance pp_instance, @@ -113,8 +116,11 @@ class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend { virtual ~ImageDataPlatformBackend(); // PPB_ImageData_Impl::Backend implementation. - virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, - int width, int height, bool init_to_zero) OVERRIDE; + virtual bool Init(PPB_ImageData_Impl* impl, + PP_ImageDataFormat format, + int width, + int height, + bool init_to_zero) OVERRIDE; virtual bool IsMapped() const OVERRIDE; virtual TransportDIB* GetTransportDIB() const OVERRIDE; virtual void* Map() OVERRIDE; @@ -145,8 +151,11 @@ class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { virtual ~ImageDataSimpleBackend(); // PPB_ImageData_Impl::Backend implementation. - virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, - int width, int height, bool init_to_zero) OVERRIDE; + virtual bool Init(PPB_ImageData_Impl* impl, + PP_ImageDataFormat format, + int width, + int height, + bool init_to_zero) OVERRIDE; virtual bool IsMapped() const OVERRIDE; virtual TransportDIB* GetTransportDIB() const OVERRIDE; virtual void* Map() OVERRIDE; @@ -179,7 +188,7 @@ class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { class ImageDataAutoMapper { public: explicit ImageDataAutoMapper(PPB_ImageData_Impl* image_data) - : image_data_(image_data) { + : image_data_(image_data) { if (image_data_->IsMapped()) { is_valid_ = true; needs_unmap_ = false; diff --git a/content/renderer/pepper/ppb_proxy_impl.cc b/content/renderer/pepper/ppb_proxy_impl.cc index cdae3ac..aeae7f3 100644 --- a/content/renderer/pepper/ppb_proxy_impl.cc +++ b/content/renderer/pepper/ppb_proxy_impl.cc @@ -59,19 +59,12 @@ PP_Bool IsInModuleDestructor(PP_Module module) { } const PPB_Proxy_Private ppb_proxy = { - &PluginCrashed, - &GetInstanceForResource, - &SetReserveInstanceIDCallback, - &AddRefModule, - &ReleaseModule, - &IsInModuleDestructor -}; + &PluginCrashed, &GetInstanceForResource, &SetReserveInstanceIDCallback, + &AddRefModule, &ReleaseModule, &IsInModuleDestructor}; } // namespace // static -const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { - return &ppb_proxy; -} +const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { return &ppb_proxy; } } // namespace content diff --git a/content/renderer/pepper/ppb_proxy_impl.h b/content/renderer/pepper/ppb_proxy_impl.h index f7341c0..e8a6a31 100644 --- a/content/renderer/pepper/ppb_proxy_impl.h +++ b/content/renderer/pepper/ppb_proxy_impl.h @@ -17,4 +17,3 @@ class PPB_Proxy_Impl { } // namespace content #endif // CONTENT_RENDERER_PEPPER_PPB_PROXY_IMPL_H_ - diff --git a/content/renderer/pepper/ppb_scrollbar_impl.cc b/content/renderer/pepper/ppb_scrollbar_impl.cc index 326c700..e276e52 100644 --- a/content/renderer/pepper/ppb_scrollbar_impl.cc +++ b/content/renderer/pepper/ppb_scrollbar_impl.cc @@ -35,21 +35,16 @@ using blink::WebPluginScrollbar; namespace content { // static -PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance, - bool vertical) { - scoped_refptr<PPB_Scrollbar_Impl> scrollbar( - new PPB_Scrollbar_Impl(instance)); +PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance, bool vertical) { + scoped_refptr<PPB_Scrollbar_Impl> scrollbar(new PPB_Scrollbar_Impl(instance)); scrollbar->Init(vertical); return scrollbar->GetReference(); } PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PP_Instance instance) - : PPB_Widget_Impl(instance), - weak_ptr_factory_(this) { -} + : PPB_Widget_Impl(instance), weak_ptr_factory_(this) {} -PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { -} +PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {} void PPB_Scrollbar_Impl::Init(bool vertical) { PepperPluginInstanceImpl* plugin_instance = @@ -62,25 +57,17 @@ void PPB_Scrollbar_Impl::Init(bool vertical) { static_cast<blink::WebPluginScrollbarClient*>(this))); } -PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { - return this; -} +PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { return this; } -void PPB_Scrollbar_Impl::InstanceWasDeleted() { - scrollbar_.reset(); -} +void PPB_Scrollbar_Impl::InstanceWasDeleted() { scrollbar_.reset(); } uint32_t PPB_Scrollbar_Impl::GetThickness() { return WebPluginScrollbar::defaultThickness(); } -bool PPB_Scrollbar_Impl::IsOverlay() { - return scrollbar_->isOverlay(); -} +bool PPB_Scrollbar_Impl::IsOverlay() { return scrollbar_->isOverlay(); } -uint32_t PPB_Scrollbar_Impl::GetValue() { - return scrollbar_->value(); -} +uint32_t PPB_Scrollbar_Impl::GetValue() { return scrollbar_->value(); } void PPB_Scrollbar_Impl::SetValue(uint32_t value) { if (scrollbar_) @@ -101,7 +88,8 @@ void PPB_Scrollbar_Impl::SetTickMarks(const PP_Rect* tick_marks, tickmarks_[i] = WebRect(tick_marks[i].point.x, tick_marks[i].point.y, tick_marks[i].size.width, - tick_marks[i].size.height);; + tick_marks[i].size.height); + ; } PP_Rect rect = location(); Invalidate(&rect); @@ -111,8 +99,9 @@ void PPB_Scrollbar_Impl::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { if (!scrollbar_) return; - WebScrollbar::ScrollDirection direction = multiplier >= 0 ? - WebScrollbar::ScrollForward : WebScrollbar::ScrollBackward; + WebScrollbar::ScrollDirection direction = multiplier >= 0 + ? WebScrollbar::ScrollForward + : WebScrollbar::ScrollBackward; float fmultiplier = 1.0; WebScrollbar::ScrollGranularity granularity; @@ -175,19 +164,18 @@ void PPB_Scrollbar_Impl::valueChanged(blink::WebPluginScrollbar* scrollbar) { return; const PPP_Scrollbar_Dev* ppp_scrollbar = - static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( - PPP_SCROLLBAR_DEV_INTERFACE)); + static_cast<const PPP_Scrollbar_Dev*>( + plugin_module->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); if (!ppp_scrollbar) { // Try the old version. This is ok because the old interface is a subset of // the new one, and ValueChanged didn't change. - ppp_scrollbar = - static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( - PPP_SCROLLBAR_DEV_INTERFACE_0_2)); + ppp_scrollbar = static_cast<const PPP_Scrollbar_Dev*>( + plugin_module->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE_0_2)); if (!ppp_scrollbar) return; } - ppp_scrollbar->ValueChanged(pp_instance(), pp_resource(), - scrollbar_->value()); + ppp_scrollbar->ValueChanged( + pp_instance(), pp_resource(), scrollbar_->value()); } void PPB_Scrollbar_Impl::overlayChanged(WebPluginScrollbar* scrollbar) { @@ -197,21 +185,18 @@ void PPB_Scrollbar_Impl::overlayChanged(WebPluginScrollbar* scrollbar) { return; const PPP_Scrollbar_Dev* ppp_scrollbar = - static_cast<const PPP_Scrollbar_Dev*>(plugin_module->GetPluginInterface( - PPP_SCROLLBAR_DEV_INTERFACE)); + static_cast<const PPP_Scrollbar_Dev*>( + plugin_module->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); if (!ppp_scrollbar) return; - ppp_scrollbar->OverlayChanged(pp_instance(), pp_resource(), - PP_FromBool(IsOverlay())); + ppp_scrollbar->OverlayChanged( + pp_instance(), pp_resource(), PP_FromBool(IsOverlay())); } void PPB_Scrollbar_Impl::invalidateScrollbarRect( blink::WebPluginScrollbar* scrollbar, const blink::WebRect& rect) { - gfx::Rect gfx_rect(rect.x, - rect.y, - rect.width, - rect.height); + gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height); dirty_.Union(gfx_rect); // Can't call into the client to tell them about the invalidate right away, // since the PPB_Scrollbar_Impl code is still in the middle of updating its diff --git a/content/renderer/pepper/ppb_scrollbar_impl.h b/content/renderer/pepper/ppb_scrollbar_impl.h index f649c81..6eeee80e 100644 --- a/content/renderer/pepper/ppb_scrollbar_impl.h +++ b/content/renderer/pepper/ppb_scrollbar_impl.h @@ -46,8 +46,8 @@ class PPB_Scrollbar_Impl : public PPB_Widget_Impl, // PPB_Widget private implementation. virtual PP_Bool PaintInternal(const gfx::Rect& rect, PPB_ImageData_Impl* image) OVERRIDE; - virtual PP_Bool HandleEventInternal( - const ppapi::InputEventData& data) OVERRIDE; + virtual PP_Bool HandleEventInternal(const ppapi::InputEventData& data) + OVERRIDE; virtual void SetLocationInternal(const PP_Rect* location) OVERRIDE; // blink::WebPluginScrollbarClient implementation. @@ -55,9 +55,9 @@ class PPB_Scrollbar_Impl : public PPB_Widget_Impl, virtual void overlayChanged(blink::WebPluginScrollbar* scrollbar) OVERRIDE; virtual void invalidateScrollbarRect(blink::WebPluginScrollbar* scrollbar, const blink::WebRect& rect) OVERRIDE; - virtual void getTickmarks( - blink::WebPluginScrollbar* scrollbar, - blink::WebVector<blink::WebRect>* tick_marks) const OVERRIDE; + virtual void getTickmarks(blink::WebPluginScrollbar* scrollbar, + blink::WebVector<blink::WebRect>* tick_marks) const + OVERRIDE; void NotifyInvalidate(); diff --git a/content/renderer/pepper/ppb_var_deprecated_impl.cc b/content/renderer/pepper/ppb_var_deprecated_impl.cc index 6f12733..f8fdd14 100644 --- a/content/renderer/pepper/ppb_var_deprecated_impl.cc +++ b/content/renderer/pepper/ppb_var_deprecated_impl.cc @@ -109,8 +109,7 @@ bool PPVarToNPVariantNoCopy(PP_Var var, NPVariant* result) { class ObjectAccessorTryCatch : public TryCatch { public: ObjectAccessorTryCatch(PP_Var object, PP_Var* exception) - : TryCatch(exception), - object_(NPObjectVar::FromPPVar(object)) { + : TryCatch(exception), object_(NPObjectVar::FromPPVar(object)) { if (!object_.get()) { SetException(kInvalidObjectException); } @@ -145,8 +144,7 @@ class ObjectAccessorWithIdentifierTryCatch : public ObjectAccessorTryCatch { ObjectAccessorWithIdentifierTryCatch(PP_Var object, PP_Var identifier, PP_Var* exception) - : ObjectAccessorTryCatch(object, exception), - identifier_(0) { + : ObjectAccessorTryCatch(object, exception), identifier_(0) { if (!has_exception()) { identifier_ = PPVarToNPIdentifier(identifier); if (!identifier_) @@ -162,43 +160,36 @@ class ObjectAccessorWithIdentifierTryCatch : public ObjectAccessorTryCatch { DISALLOW_COPY_AND_ASSIGN(ObjectAccessorWithIdentifierTryCatch); }; -PP_Bool HasProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Bool HasProperty(PP_Var var, PP_Var name, PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) return PP_FALSE; - return BoolToPPBool(WebBindings::hasProperty(NULL, - accessor.object()->np_object(), - accessor.identifier())); + return BoolToPPBool(WebBindings::hasProperty( + NULL, accessor.object()->np_object(), accessor.identifier())); } -bool HasPropertyDeprecated(PP_Var var, - PP_Var name, - PP_Var* exception) { +bool HasPropertyDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { return PPBoolToBool(HasProperty(var, name, exception)); } -bool HasMethodDeprecated(PP_Var var, - PP_Var name, - PP_Var* exception) { +bool HasMethodDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) return false; - return WebBindings::hasMethod(NULL, accessor.object()->np_object(), - accessor.identifier()); + return WebBindings::hasMethod( + NULL, accessor.object()->np_object(), accessor.identifier()); } -PP_Var GetProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Var GetProperty(PP_Var var, PP_Var name, PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) return PP_MakeUndefined(); NPVariant result; - if (!WebBindings::getProperty(NULL, accessor.object()->np_object(), - accessor.identifier(), &result)) { + if (!WebBindings::getProperty(NULL, + accessor.object()->np_object(), + accessor.identifier(), + &result)) { // An exception may have been raised. accessor.SetException(kUnableToGetPropertyException); return PP_MakeUndefined(); @@ -222,8 +213,8 @@ void EnumerateProperties(PP_Var var, NPIdentifier* identifiers = NULL; uint32_t count = 0; - if (!WebBindings::enumerate(NULL, accessor.object()->np_object(), - &identifiers, &count)) { + if (!WebBindings::enumerate( + NULL, accessor.object()->np_object(), &identifiers, &count)) { accessor.SetException(kUnableToGetAllPropertiesException); return; } @@ -252,20 +243,20 @@ void SetPropertyDeprecated(PP_Var var, accessor.SetException(kInvalidValueException); return; } - if (!WebBindings::setProperty(NULL, accessor.object()->np_object(), - accessor.identifier(), &variant)) + if (!WebBindings::setProperty(NULL, + accessor.object()->np_object(), + accessor.identifier(), + &variant)) accessor.SetException(kUnableToSetPropertyException); } -void DeletePropertyDeprecated(PP_Var var, - PP_Var name, - PP_Var* exception) { +void DeletePropertyDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) return; - if (!WebBindings::removeProperty(NULL, accessor.object()->np_object(), - accessor.identifier())) + if (!WebBindings::removeProperty( + NULL, accessor.object()->np_object(), accessor.identifier())) accessor.SetException(kUnableToRemovePropertyException); } @@ -305,11 +296,15 @@ PP_Var InternalCallDeprecated(ObjectAccessorTryCatch* accessor, NPVariant result; if (identifier) { - ok = WebBindings::invoke(NULL, accessor->object()->np_object(), - identifier, args.get(), argc, &result); + ok = WebBindings::invoke(NULL, + accessor->object()->np_object(), + identifier, + args.get(), + argc, + &result); } else { - ok = WebBindings::invokeDefault(NULL, accessor->object()->np_object(), - args.get(), argc, &result); + ok = WebBindings::invokeDefault( + NULL, accessor->object()->np_object(), args.get(), argc, &result); } if (!ok) { @@ -333,18 +328,14 @@ PP_Var CallDeprecated(PP_Var var, return PP_MakeUndefined(); PepperPluginInstanceImpl* plugin = accessor.GetPluginInstance(); if (plugin && plugin->IsProcessingUserGesture()) { - blink::WebScopedUserGesture user_gesture( - plugin->CurrentUserGestureToken()); - return InternalCallDeprecated(&accessor, method_name, argc, argv, - exception); + blink::WebScopedUserGesture user_gesture(plugin->CurrentUserGestureToken()); + return InternalCallDeprecated( + &accessor, method_name, argc, argv, exception); } return InternalCallDeprecated(&accessor, method_name, argc, argv, exception); } -PP_Var Construct(PP_Var var, - uint32_t argc, - PP_Var* argv, - PP_Var* exception) { +PP_Var Construct(PP_Var var, uint32_t argc, PP_Var* argv, PP_Var* exception) { ObjectAccessorTryCatch accessor(var, exception); if (accessor.has_exception()) return PP_MakeUndefined(); @@ -362,8 +353,8 @@ PP_Var Construct(PP_Var var, } NPVariant result; - if (!WebBindings::construct(NULL, accessor.object()->np_object(), - args.get(), argc, &result)) { + if (!WebBindings::construct( + NULL, accessor.object()->np_object(), args.get(), argc, &result)) { // An exception may have been raised. accessor.SetException(kUnableToConstructException); return PP_MakeUndefined(); @@ -381,8 +372,8 @@ bool IsInstanceOfDeprecated(PP_Var var, if (!object.get()) return false; // Not an object at all. - return PluginObject::IsInstanceOf(object->np_object(), - ppp_class, ppp_class_data); + return PluginObject::IsInstanceOf( + object->np_object(), ppp_class, ppp_class_data); } PP_Var CreateObjectDeprecated(PP_Instance pp_instance, @@ -403,8 +394,8 @@ PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module, PluginModule* module = HostGlobals::Get()->GetModule(pp_module); if (!module) return PP_MakeNull(); - return PluginObject::Create(module->GetSomeInstance(), - ppp_class, ppp_class_data); + return PluginObject::Create( + module->GetSomeInstance(), ppp_class, ppp_class_data); } } // namespace @@ -412,25 +403,23 @@ PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module, // static const PPB_Var_Deprecated* PPB_Var_Deprecated_Impl::GetVarDeprecatedInterface() { static const PPB_Var_Deprecated var_deprecated_interface = { - ppapi::PPB_Var_Shared::GetVarInterface1_0()->AddRef, - ppapi::PPB_Var_Shared::GetVarInterface1_0()->Release, - ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarFromUtf8, - ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarToUtf8, - &HasPropertyDeprecated, - &HasMethodDeprecated, - &GetProperty, - &EnumerateProperties, - &SetPropertyDeprecated, - &DeletePropertyDeprecated, - &CallDeprecated, - &Construct, - &IsInstanceOfDeprecated, - &CreateObjectDeprecated, - &CreateObjectWithModuleDeprecated, - }; + ppapi::PPB_Var_Shared::GetVarInterface1_0()->AddRef, + ppapi::PPB_Var_Shared::GetVarInterface1_0()->Release, + ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarFromUtf8, + ppapi::PPB_Var_Shared::GetVarInterface1_0()->VarToUtf8, + &HasPropertyDeprecated, + &HasMethodDeprecated, + &GetProperty, + &EnumerateProperties, + &SetPropertyDeprecated, + &DeletePropertyDeprecated, + &CallDeprecated, + &Construct, + &IsInstanceOfDeprecated, + &CreateObjectDeprecated, + &CreateObjectWithModuleDeprecated, }; return &var_deprecated_interface; } } // namespace content - diff --git a/content/renderer/pepper/ppb_video_decoder_impl.cc b/content/renderer/pepper/ppb_video_decoder_impl.cc index 05feadc..bf9e90f 100644 --- a/content/renderer/pepper/ppb_video_decoder_impl.cc +++ b/content/renderer/pepper/ppb_video_decoder_impl.cc @@ -41,10 +41,10 @@ media::VideoCodecProfile PPToMediaProfile( const PP_VideoDecoder_Profile pp_profile) { switch (pp_profile) { case PP_VIDEODECODER_H264PROFILE_NONE: - // HACK: PPAPI contains a bogus "none" h264 profile that doesn't - // correspond to anything in h.264; but a number of released chromium - // versions silently promoted this to Baseline profile, so we retain that - // behavior here. Fall through. + // HACK: PPAPI contains a bogus "none" h264 profile that doesn't + // correspond to anything in h.264; but a number of released chromium + // versions silently promoted this to Baseline profile, so we retain that + // behavior here. Fall through. case PP_VIDEODECODER_H264PROFILE_BASELINE: return media::H264PROFILE_BASELINE; case PP_VIDEODECODER_H264PROFILE_MAIN: @@ -77,13 +77,13 @@ media::VideoCodecProfile PPToMediaProfile( PP_VideoDecodeError_Dev MediaToPPError( media::VideoDecodeAccelerator::Error error) { switch (error) { - case media::VideoDecodeAccelerator::ILLEGAL_STATE : + case media::VideoDecodeAccelerator::ILLEGAL_STATE: return PP_VIDEODECODERERROR_ILLEGAL_STATE; - case media::VideoDecodeAccelerator::INVALID_ARGUMENT : + case media::VideoDecodeAccelerator::INVALID_ARGUMENT: return PP_VIDEODECODERERROR_INVALID_ARGUMENT; - case media::VideoDecodeAccelerator::UNREADABLE_INPUT : + case media::VideoDecodeAccelerator::UNREADABLE_INPUT: return PP_VIDEODECODERERROR_UNREADABLE_INPUT; - case media::VideoDecodeAccelerator::PLATFORM_FAILURE : + case media::VideoDecodeAccelerator::PLATFORM_FAILURE: return PP_VIDEODECODERERROR_PLATFORM_FAILURE; default: NOTREACHED(); @@ -96,8 +96,7 @@ PP_VideoDecodeError_Dev MediaToPPError( namespace content { PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) - : PPB_VideoDecoder_Shared(instance), - ppp_videodecoder_(NULL) { + : PPB_VideoDecoder_Shared(instance), ppp_videodecoder_(NULL) { PluginModule* plugin_module = HostGlobals::Get()->GetInstance(pp_instance())->module(); if (plugin_module) { @@ -106,15 +105,12 @@ PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) } } -PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { - Destroy(); -} +PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { Destroy(); } // static -PP_Resource PPB_VideoDecoder_Impl::Create( - PP_Instance instance, - PP_Resource graphics_context, - PP_VideoDecoder_Profile profile) { +PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, + PP_Resource graphics_context, + PP_VideoDecoder_Profile profile) { EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, true); if (enter_context.failed()) return 0; @@ -123,17 +119,18 @@ PP_Resource PPB_VideoDecoder_Impl::Create( scoped_refptr<PPB_VideoDecoder_Impl> decoder( new PPB_VideoDecoder_Impl(instance)); - if (decoder->Init(graphics_context, graphics3d_impl->platform_context(), - graphics3d_impl->gles2_impl(), profile)) + if (decoder->Init(graphics_context, + graphics3d_impl->platform_context(), + graphics3d_impl->gles2_impl(), + profile)) return decoder->GetReference(); return 0; } -bool PPB_VideoDecoder_Impl::Init( - PP_Resource graphics_context, - PlatformContext3D* context, - gpu::gles2::GLES2Implementation* gles2_impl, - PP_VideoDecoder_Profile profile) { +bool PPB_VideoDecoder_Impl::Init(PP_Resource graphics_context, + PlatformContext3D* context, + gpu::gles2::GLES2Implementation* gles2_impl, + PP_VideoDecoder_Profile profile) { InitCommon(graphics_context, gles2_impl); int command_buffer_route_id = context->GetCommandBufferRouteId(); @@ -161,10 +158,9 @@ int32_t PPB_VideoDecoder_Impl::Decode( PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); DCHECK_GE(bitstream_buffer->id, 0); - media::BitstreamBuffer decode_buffer( - bitstream_buffer->id, - buffer->shared_memory()->handle(), - bitstream_buffer->size); + media::BitstreamBuffer decode_buffer(bitstream_buffer->id, + buffer->shared_memory()->handle(), + bitstream_buffer->size); if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) return PP_ERROR_BADARGUMENT; @@ -248,8 +244,11 @@ void PPB_VideoDecoder_Impl::ProvidePictureBuffers( return; PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); - ppp_videodecoder_->ProvidePictureBuffers(pp_instance(), pp_resource(), - requested_num_of_buffers, &out_dim, texture_target); + ppp_videodecoder_->ProvidePictureBuffers(pp_instance(), + pp_resource(), + requested_num_of_buffers, + &out_dim, + texture_target); } void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { @@ -265,8 +264,8 @@ void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { if (!ppp_videodecoder_) return; - ppp_videodecoder_->DismissPictureBuffer(pp_instance(), pp_resource(), - picture_buffer_id); + ppp_videodecoder_->DismissPictureBuffer( + pp_instance(), pp_resource(), picture_buffer_id); } void PPB_VideoDecoder_Impl::NotifyError( @@ -276,22 +275,18 @@ void PPB_VideoDecoder_Impl::NotifyError( PP_VideoDecodeError_Dev pp_error = MediaToPPError(error); ppp_videodecoder_->NotifyError(pp_instance(), pp_resource(), pp_error); - UMA_HISTOGRAM_ENUMERATION( - "Media.PepperVideoDecoderError", error, - media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM); + UMA_HISTOGRAM_ENUMERATION("Media.PepperVideoDecoderError", + error, + media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM); } -void PPB_VideoDecoder_Impl::NotifyResetDone() { - RunResetCallback(PP_OK); -} +void PPB_VideoDecoder_Impl::NotifyResetDone() { RunResetCallback(PP_OK); } void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( int32 bitstream_buffer_id) { RunBitstreamBufferCallback(bitstream_buffer_id, PP_OK); } -void PPB_VideoDecoder_Impl::NotifyFlushDone() { - RunFlushCallback(PP_OK); -} +void PPB_VideoDecoder_Impl::NotifyFlushDone() { RunFlushCallback(PP_OK); } } // namespace content diff --git a/content/renderer/pepper/ppb_video_decoder_impl.h b/content/renderer/pepper/ppb_video_decoder_impl.h index e5ed3a3..ad782f1 100644 --- a/content/renderer/pepper/ppb_video_decoder_impl.h +++ b/content/renderer/pepper/ppb_video_decoder_impl.h @@ -39,16 +39,17 @@ class PPB_VideoDecoder_Impl : public ppapi::PPB_VideoDecoder_Shared, PP_VideoDecoder_Profile profile); // PPB_VideoDecoder_API implementation. - virtual int32_t Decode( - const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, - scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE; - virtual void AssignPictureBuffers( - uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; + virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, + scoped_refptr<ppapi::TrackedCallback> callback) + OVERRIDE; + virtual void AssignPictureBuffers(uint32_t no_of_buffers, + const PP_PictureBuffer_Dev* buffers) + OVERRIDE; virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; - virtual int32_t Flush( - scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE; - virtual int32_t Reset( - scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE; + virtual int32_t Flush(scoped_refptr<ppapi::TrackedCallback> callback) + OVERRIDE; + virtual int32_t Reset(scoped_refptr<ppapi::TrackedCallback> callback) + OVERRIDE; virtual void Destroy() OVERRIDE; // media::VideoDecodeAccelerator::Client implementation. @@ -57,8 +58,7 @@ class PPB_VideoDecoder_Impl : public ppapi::PPB_VideoDecoder_Shared, uint32 texture_target) OVERRIDE; virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; virtual void PictureReady(const media::Picture& picture) OVERRIDE; - virtual void NotifyError( - media::VideoDecodeAccelerator::Error error) OVERRIDE; + virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; virtual void NotifyFlushDone() OVERRIDE; virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; virtual void NotifyResetDone() OVERRIDE; diff --git a/content/renderer/pepper/ppb_widget_impl.cc b/content/renderer/pepper/ppb_widget_impl.cc index 494eec7..c28d566 100644 --- a/content/renderer/pepper/ppb_widget_impl.cc +++ b/content/renderer/pepper/ppb_widget_impl.cc @@ -21,25 +21,22 @@ using ppapi::thunk::PPB_Widget_API; namespace content { PPB_Widget_Impl::PPB_Widget_Impl(PP_Instance instance) - : Resource(ppapi::OBJECT_IS_IMPL, instance), - scale_(1.0f) { + : Resource(ppapi::OBJECT_IS_IMPL, instance), scale_(1.0f) { memset(&location_, 0, sizeof(location_)); } -PPB_Widget_Impl::~PPB_Widget_Impl() { -} +PPB_Widget_Impl::~PPB_Widget_Impl() {} -PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() { - return this; -} +PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() { return this; } PP_Bool PPB_Widget_Impl::Paint(const PP_Rect* rect, PP_Resource image_id) { EnterResourceNoLock<PPB_ImageData_API> enter(image_id, true); if (enter.failed()) return PP_FALSE; - return PaintInternal(gfx::Rect(rect->point.x, rect->point.y, - rect->size.width, rect->size.height), - static_cast<PPB_ImageData_Impl*>(enter.object())); + return PaintInternal( + gfx::Rect( + rect->point.x, rect->point.y, rect->size.width, rect->size.height), + static_cast<PPB_ImageData_Impl*>(enter.object())); } PP_Bool PPB_Widget_Impl::HandleEvent(PP_Resource pp_input_event) { @@ -59,9 +56,7 @@ void PPB_Widget_Impl::SetLocation(const PP_Rect* location) { SetLocationInternal(location); } -void PPB_Widget_Impl::SetScale(float scale) { - scale_ = scale; -} +void PPB_Widget_Impl::SetScale(float scale) { scale_ = scale; } void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) { PepperPluginInstanceImpl* plugin_instance = @@ -76,4 +71,3 @@ void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) { } } // namespace content - diff --git a/content/renderer/pepper/ppb_widget_impl.h b/content/renderer/pepper/ppb_widget_impl.h index 66139ca..db6feb3 100644 --- a/content/renderer/pepper/ppb_widget_impl.h +++ b/content/renderer/pepper/ppb_widget_impl.h @@ -31,7 +31,7 @@ class PPB_Widget_Impl : public ppapi::Resource, virtual ppapi::thunk::PPB_Widget_API* AsPPB_Widget_API() OVERRIDE; // PPB_WidgetAPI implementation. - virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource ) OVERRIDE; + virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource) OVERRIDE; virtual PP_Bool HandleEvent(PP_Resource pp_input_event) OVERRIDE; virtual PP_Bool GetLocation(PP_Rect* location) OVERRIDE; virtual void SetLocation(const PP_Rect* location) OVERRIDE; diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.cc b/content/renderer/pepper/renderer_ppapi_host_impl.cc index afb5f12..22e7f46 100644 --- a/content/renderer/pepper/renderer_ppapi_host_impl.cc +++ b/content/renderer/pepper/renderer_ppapi_host_impl.cc @@ -31,8 +31,8 @@ namespace content { // static -CONTENT_EXPORT RendererPpapiHost* -RendererPpapiHost::GetForPPInstance(PP_Instance instance) { +CONTENT_EXPORT RendererPpapiHost* RendererPpapiHost::GetForPPInstance( + PP_Instance instance) { return RendererPpapiHostImpl::GetForPPInstance(instance); } @@ -41,11 +41,9 @@ RendererPpapiHostImpl::RendererPpapiHostImpl( PluginModule* module, ppapi::proxy::HostDispatcher* dispatcher, const ppapi::PpapiPermissions& permissions) - : module_(module), - dispatcher_(dispatcher) { + : module_(module), dispatcher_(dispatcher) { // Hook the PpapiHost up to the dispatcher for out-of-process communication. - ppapi_host_.reset( - new ppapi::host::PpapiHost(dispatcher, permissions)); + ppapi_host_.reset(new ppapi::host::PpapiHost(dispatcher, permissions)); ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( new ContentRendererPepperHostFactory(this))); dispatcher->AddFilter(ppapi_host_.get()); @@ -56,8 +54,7 @@ RendererPpapiHostImpl::RendererPpapiHostImpl( RendererPpapiHostImpl::RendererPpapiHostImpl( PluginModule* module, const ppapi::PpapiPermissions& permissions) - : module_(module), - dispatcher_(NULL) { + : module_(module), dispatcher_(NULL) { // Hook the host up to the in-process router. in_process_router_.reset(new PepperInProcessRouter(this)); ppapi_host_.reset(new ppapi::host::PpapiHost( @@ -80,8 +77,8 @@ RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( ppapi::proxy::HostDispatcher* dispatcher, const ppapi::PpapiPermissions& permissions) { DCHECK(!module->renderer_ppapi_host()); - RendererPpapiHostImpl* result = new RendererPpapiHostImpl( - module, dispatcher, permissions); + RendererPpapiHostImpl* result = + new RendererPpapiHostImpl(module, dispatcher, permissions); // Takes ownership of pointer. module->SetRendererPpapiHost(scoped_ptr<RendererPpapiHostImpl>(result)); @@ -94,8 +91,8 @@ RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForInProcess( PluginModule* module, const ppapi::PpapiPermissions& permissions) { DCHECK(!module->renderer_ppapi_host()); - RendererPpapiHostImpl* result = new RendererPpapiHostImpl( - module, permissions); + RendererPpapiHostImpl* result = + new RendererPpapiHostImpl(module, permissions); // Takes ownership of pointer. module->SetRendererPpapiHost(scoped_ptr<RendererPpapiHostImpl>(result)); @@ -133,7 +130,7 @@ ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { } RenderFrame* RendererPpapiHostImpl::GetRenderFrameForInstance( - PP_Instance instance) const { + PP_Instance instance) const { PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); if (!instance_object) return NULL; @@ -164,7 +161,7 @@ PepperPluginInstance* RendererPpapiHostImpl::GetPluginInstance( } blink::WebPluginContainer* RendererPpapiHostImpl::GetContainerForInstance( - PP_Instance instance) const { + PP_Instance instance) const { PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); if (!instance_object) return NULL; @@ -220,9 +217,8 @@ IPC::PlatformFileForTransit RendererPpapiHostImpl::ShareHandleWithRemote( // Duplicate the file handle for in process mode so this function // has the same semantics for both in process mode and out of // process mode (i.e., the remote side must cloes the handle). - return BrokerGetFileHandleForProcess(handle, - base::GetCurrentProcId(), - should_close_source); + return BrokerGetFileHandleForProcess( + handle, base::GetCurrentProcId(), should_close_source); } return dispatcher_->ShareHandleWithRemote(handle, should_close_source); } @@ -239,13 +235,12 @@ void RendererPpapiHostImpl::CreateBrowserResourceHosts( PepperBrowserConnection* browser_connection = PepperBrowserConnection::Get(render_frame); if (!browser_connection) { - base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(callback, std::vector<int>(nested_msgs.size(), 0))); } else { - browser_connection->SendBrowserCreate(module_->GetPluginChildId(), - instance, - nested_msgs, - callback); + browser_connection->SendBrowserCreate( + module_->GetPluginChildId(), instance, nested_msgs, callback); } } diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.h b/content/renderer/pepper/renderer_ppapi_host_impl.h index c2ad0d1..8da1411 100644 --- a/content/renderer/pepper/renderer_ppapi_host_impl.h +++ b/content/renderer/pepper/renderer_ppapi_host_impl.h @@ -76,20 +76,20 @@ class RendererPpapiHostImpl : public RendererPpapiHost { // RendererPpapiHost implementation. virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; - virtual PepperPluginInstance* GetPluginInstance( - PP_Instance instance) const OVERRIDE; - virtual RenderFrame* GetRenderFrameForInstance( - PP_Instance instance) const OVERRIDE; - virtual RenderView* GetRenderViewForInstance( - PP_Instance instance) const OVERRIDE; + virtual PepperPluginInstance* GetPluginInstance(PP_Instance instance) const + OVERRIDE; + virtual RenderFrame* GetRenderFrameForInstance(PP_Instance instance) const + OVERRIDE; + virtual RenderView* GetRenderViewForInstance(PP_Instance instance) const + OVERRIDE; virtual blink::WebPluginContainer* GetContainerForInstance( PP_Instance instance) const OVERRIDE; virtual base::ProcessId GetPluginPID() const OVERRIDE; virtual bool HasUserGesture(PP_Instance instance) const OVERRIDE; virtual int GetRoutingIDForWidget(PP_Instance instance) const OVERRIDE; - virtual gfx::Point PluginPointToRenderFrame( - PP_Instance instance, - const gfx::Point& pt) const OVERRIDE; + virtual gfx::Point PluginPointToRenderFrame(PP_Instance instance, + const gfx::Point& pt) const + OVERRIDE; virtual IPC::PlatformFileForTransit ShareHandleWithRemote( base::PlatformFile handle, bool should_close_source) OVERRIDE; @@ -97,8 +97,8 @@ class RendererPpapiHostImpl : public RendererPpapiHost { virtual void CreateBrowserResourceHosts( PP_Instance instance, const std::vector<IPC::Message>& nested_msgs, - const base::Callback<void( - const std::vector<int>&)>& callback) const OVERRIDE; + const base::Callback<void(const std::vector<int>&)>& callback) const + OVERRIDE; virtual GURL GetDocumentURL(PP_Instance instance) const OVERRIDE; private: diff --git a/content/renderer/pepper/resource_converter.cc b/content/renderer/pepper/resource_converter.cc index 0ec93ba..5fef938 100644 --- a/content/renderer/pepper/resource_converter.cc +++ b/content/renderer/pepper/resource_converter.cc @@ -105,9 +105,8 @@ bool DOMFileSystemToResource( } *pending_renderer_id = host->GetPpapiHost()->AddPendingResourceHost( - scoped_ptr<ppapi::host::ResourceHost>( - new PepperFileSystemHost(host, instance, 0, root_url, - file_system_type))); + scoped_ptr<ppapi::host::ResourceHost>(new PepperFileSystemHost( + host, instance, 0, root_url, file_system_type))); if (*pending_renderer_id == 0) return false; @@ -188,9 +187,7 @@ ResourceConverter::~ResourceConverter() {} ResourceConverterImpl::ResourceConverterImpl(PP_Instance instance, RendererPpapiHost* host) - : instance_(instance), - host_(host) { -} + : instance_(instance), host_(host) {} ResourceConverterImpl::~ResourceConverterImpl() { // Verify Flush() was called. @@ -213,8 +210,11 @@ bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, int pending_renderer_id; scoped_ptr<IPC::Message> create_message; scoped_ptr<IPC::Message> browser_host_create_message; - if (!DOMFileSystemToResource(instance_, host_, dom_file_system, - &pending_renderer_id, &create_message, + if (!DOMFileSystemToResource(instance_, + host_, + dom_file_system, + &pending_renderer_id, + &create_message, &browser_host_create_message)) { return false; } @@ -233,13 +233,16 @@ bool ResourceConverterImpl::FromV8Value(v8::Handle<v8::Object> val, if (!dom_media_stream_track.isNull()) { int pending_renderer_id; scoped_ptr<IPC::Message> create_message; - if (!DOMMediaStreamTrackToResource(instance_, host_, dom_media_stream_track, - &pending_renderer_id, &create_message)) { + if (!DOMMediaStreamTrackToResource(instance_, + host_, + dom_media_stream_track, + &pending_renderer_id, + &create_message)) { return false; } DCHECK(create_message); - scoped_refptr<HostResourceVar> result_var = CreateResourceVar( - pending_renderer_id, *create_message); + scoped_refptr<HostResourceVar> result_var = + CreateResourceVar(pending_renderer_id, *create_message); *result = result_var->GetPPVar(); *was_resource = true; return true; @@ -282,8 +285,7 @@ bool ResourceConverterImpl::ToV8Value(const PP_Var& var, NOTREACHED(); return false; } - ::ppapi::host::PpapiHost* ppapi_host = - renderer_ppapi_host->GetPpapiHost(); + ::ppapi::host::PpapiHost* ppapi_host = renderer_ppapi_host->GetPpapiHost(); ::ppapi::host::ResourceHost* resource_host = ppapi_host->GetResourceHost(resource_id); if (resource_host == NULL) { diff --git a/content/renderer/pepper/resource_creation_impl.cc b/content/renderer/pepper/resource_creation_impl.cc index 5d2c0ee..1a698b1 100644 --- a/content/renderer/pepper/resource_creation_impl.cc +++ b/content/renderer/pepper/resource_creation_impl.cc @@ -29,8 +29,7 @@ namespace content { ResourceCreationImpl::ResourceCreationImpl(PepperPluginInstanceImpl* instance) { } -ResourceCreationImpl::~ResourceCreationImpl() { -} +ResourceCreationImpl::~ResourceCreationImpl() {} PP_Resource ResourceCreationImpl::CreateAudio1_0( PP_Instance instance, @@ -40,11 +39,10 @@ PP_Resource ResourceCreationImpl::CreateAudio1_0( return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateAudio( - PP_Instance instance, - PP_Resource config_id, - PPB_Audio_Callback audio_callback, - void* user_data) { +PP_Resource ResourceCreationImpl::CreateAudio(PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback audio_callback, + void* user_data) { return 0; // Not supported in-process. } @@ -56,8 +54,7 @@ PP_Resource ResourceCreationImpl::CreateAudioConfig( ppapi::OBJECT_IS_IMPL, instance, sample_rate, sample_frame_count); } -PP_Resource ResourceCreationImpl::CreateAudioTrusted( - PP_Instance instance) { +PP_Resource ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance) { return (new PPB_Audio_Impl(instance))->GetReference(); } @@ -95,10 +92,9 @@ PP_Resource ResourceCreationImpl::CreateFlashMessageLoop(PP_Instance instance) { return PPB_Flash_MessageLoop_Impl::Create(instance); } -PP_Resource ResourceCreationImpl::CreateGraphics3D( - PP_Instance instance, - PP_Resource share_context, - const int32_t* attrib_list) { +PP_Resource ResourceCreationImpl::CreateGraphics3D(PP_Instance instance, + PP_Resource share_context, + const int32_t* attrib_list) { return PPB_Graphics3D_Impl::Create(instance, share_context, attrib_list); } @@ -118,14 +114,15 @@ PP_Resource ResourceCreationImpl::CreateHostResolverPrivate( return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateImageData( - PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) { +PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, + PP_ImageDataFormat format, + const PP_Size* size, + PP_Bool init_to_zero) { return PPB_ImageData_Impl::Create(instance, ppapi::PPB_ImageData_Shared::PLATFORM, - format, *size, init_to_zero); + format, + *size, + init_to_zero); } PP_Resource ResourceCreationImpl::CreateImageDataSimple( @@ -135,7 +132,9 @@ PP_Resource ResourceCreationImpl::CreateImageDataSimple( PP_Bool init_to_zero) { return PPB_ImageData_Impl::Create(instance, ppapi::PPB_ImageData_Shared::SIMPLE, - format, *size, init_to_zero); + format, + *size, + init_to_zero); } PP_Resource ResourceCreationImpl::CreateIMEInputEvent( @@ -148,9 +147,16 @@ PP_Resource ResourceCreationImpl::CreateIMEInputEvent( int32_t target_segment, uint32_t selection_start, uint32_t selection_end) { - return PPB_InputEvent_Shared::CreateIMEInputEvent( - ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, text, segment_number, - segment_offsets, target_segment, selection_start, selection_end); + return PPB_InputEvent_Shared::CreateIMEInputEvent(ppapi::OBJECT_IS_IMPL, + instance, + type, + time_stamp, + text, + segment_number, + segment_offsets, + target_segment, + selection_start, + selection_end); } PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0( @@ -161,9 +167,14 @@ PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_0( uint32_t key_code, struct PP_Var character_text) { PP_Var code = StringVar::StringToPPVar(""); - return PPB_InputEvent_Shared::CreateKeyboardInputEvent( - ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers, key_code, - character_text, code); + return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL, + instance, + type, + time_stamp, + modifiers, + key_code, + character_text, + code); } PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2( @@ -174,9 +185,14 @@ PP_Resource ResourceCreationImpl::CreateKeyboardInputEvent_1_2( uint32_t key_code, struct PP_Var character_text, struct PP_Var code) { - return PPB_InputEvent_Shared::CreateKeyboardInputEvent( - ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers, key_code, - character_text, code); + return PPB_InputEvent_Shared::CreateKeyboardInputEvent(ppapi::OBJECT_IS_IMPL, + instance, + type, + time_stamp, + modifiers, + key_code, + character_text, + code); } PP_Resource ResourceCreationImpl::CreateMouseInputEvent( @@ -188,9 +204,15 @@ PP_Resource ResourceCreationImpl::CreateMouseInputEvent( const PP_Point* mouse_position, int32_t click_count, const PP_Point* mouse_movement) { - return PPB_InputEvent_Shared::CreateMouseInputEvent( - ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers, - mouse_button, mouse_position, click_count, mouse_movement); + return PPB_InputEvent_Shared::CreateMouseInputEvent(ppapi::OBJECT_IS_IMPL, + instance, + type, + time_stamp, + modifiers, + mouse_button, + mouse_position, + click_count, + mouse_movement); } PP_Resource ResourceCreationImpl::CreateNetAddressFromIPv4Address( @@ -211,11 +233,10 @@ PP_Resource ResourceCreationImpl::CreateNetAddressFromNetAddressPrivate( return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateTouchInputEvent( - PP_Instance instance, - PP_InputEvent_Type type, - PP_TimeTicks time_stamp, - uint32_t modifiers) { +PP_Resource ResourceCreationImpl::CreateTouchInputEvent(PP_Instance instance, + PP_InputEvent_Type type, + PP_TimeTicks time_stamp, + uint32_t modifiers) { return PPB_InputEvent_Shared::CreateTouchInputEvent( ppapi::OBJECT_IS_IMPL, instance, type, time_stamp, modifiers); } @@ -279,13 +300,11 @@ PP_Resource ResourceCreationImpl::CreateVideoDecoder( return PPB_VideoDecoder_Impl::Create(instance, graphics3d_id, profile); } -PP_Resource ResourceCreationImpl::CreateVideoDestination( - PP_Instance instance) { +PP_Resource ResourceCreationImpl::CreateVideoDestination(PP_Instance instance) { return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateVideoSource( - PP_Instance instance) { +PP_Resource ResourceCreationImpl::CreateVideoSource(PP_Instance instance) { return 0; // Not supported in-process. } @@ -296,9 +315,13 @@ PP_Resource ResourceCreationImpl::CreateWheelInputEvent( const PP_FloatPoint* wheel_delta, const PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page) { - return PPB_InputEvent_Shared::CreateWheelInputEvent( - ppapi::OBJECT_IS_IMPL, instance, time_stamp, modifiers, - wheel_delta, wheel_ticks, scroll_by_page); + return PPB_InputEvent_Shared::CreateWheelInputEvent(ppapi::OBJECT_IS_IMPL, + instance, + time_stamp, + modifiers, + wheel_delta, + wheel_ticks, + scroll_by_page); } PP_Resource ResourceCreationImpl::CreateX509CertificatePrivate( diff --git a/content/renderer/pepper/resource_creation_impl.h b/content/renderer/pepper/resource_creation_impl.h index 0f20b62..55a0d7c 100644 --- a/content/renderer/pepper/resource_creation_impl.h +++ b/content/renderer/pepper/resource_creation_impl.h @@ -72,21 +72,20 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI { int32_t target_segment, uint32_t selection_start, uint32_t selection_end) OVERRIDE; - virtual PP_Resource CreateKeyboardInputEvent_1_0( - PP_Instance instance, - PP_InputEvent_Type type, - PP_TimeTicks time_stamp, - uint32_t modifiers, - uint32_t key_code, - PP_Var character_text) OVERRIDE; - virtual PP_Resource CreateKeyboardInputEvent_1_2( - PP_Instance instance, - PP_InputEvent_Type type, - PP_TimeTicks time_stamp, - uint32_t modifiers, - uint32_t key_code, - PP_Var character_text, - PP_Var code) OVERRIDE; + virtual PP_Resource CreateKeyboardInputEvent_1_0(PP_Instance instance, + PP_InputEvent_Type type, + PP_TimeTicks time_stamp, + uint32_t modifiers, + uint32_t key_code, + PP_Var character_text) + OVERRIDE; + virtual PP_Resource CreateKeyboardInputEvent_1_2(PP_Instance instance, + PP_InputEvent_Type type, + PP_TimeTicks time_stamp, + uint32_t modifiers, + uint32_t key_code, + PP_Var character_text, + PP_Var code) OVERRIDE; virtual PP_Resource CreateMouseInputEvent( PP_Instance instance, PP_InputEvent_Type type, @@ -105,44 +104,40 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI { virtual PP_Resource CreateNetAddressFromNetAddressPrivate( PP_Instance instance, const PP_NetAddress_Private& private_addr) OVERRIDE; - virtual PP_Resource CreateTouchInputEvent( - PP_Instance instance, - PP_InputEvent_Type type, - PP_TimeTicks time_stamp, - uint32_t modifiers) OVERRIDE; + virtual PP_Resource CreateTouchInputEvent(PP_Instance instance, + PP_InputEvent_Type type, + PP_TimeTicks time_stamp, + uint32_t modifiers) OVERRIDE; virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreatePlatformVerificationPrivate( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreatePlatformVerificationPrivate(PP_Instance instance) + OVERRIDE; virtual PP_Resource CreateScrollbar(PP_Instance instance, PP_Bool vertical) OVERRIDE; - virtual PP_Resource CreateOutputProtectionPrivate( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateOutputProtectionPrivate(PP_Instance instance) + OVERRIDE; virtual PP_Resource CreateTalk(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateTCPServerSocketPrivate( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateTCPServerSocketPrivate(PP_Instance instance) + OVERRIDE; virtual PP_Resource CreateTCPSocket1_0(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTCPSocket(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateVideoDecoder( - PP_Instance instance, - PP_Resource graphics3d_id, - PP_VideoDecoder_Profile profile) OVERRIDE; - virtual PP_Resource CreateVideoDestination( - PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateVideoSource( - PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateWheelInputEvent( - PP_Instance instance, - PP_TimeTicks time_stamp, - uint32_t modifiers, - const PP_FloatPoint* wheel_delta, - const PP_FloatPoint* wheel_ticks, - PP_Bool scroll_by_page) OVERRIDE; - virtual PP_Resource CreateX509CertificatePrivate( - PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateVideoDecoder(PP_Instance instance, + PP_Resource graphics3d_id, + PP_VideoDecoder_Profile profile) + OVERRIDE; + virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateWheelInputEvent(PP_Instance instance, + PP_TimeTicks time_stamp, + uint32_t modifiers, + const PP_FloatPoint* wheel_delta, + const PP_FloatPoint* wheel_ticks, + PP_Bool scroll_by_page) OVERRIDE; + virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) + OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ResourceCreationImpl); diff --git a/content/renderer/pepper/url_request_info_util.cc b/content/renderer/pepper/url_request_info_util.cc index 101fe04..50e2a24 100644 --- a/content/renderer/pepper/url_request_info_util.cc +++ b/content/renderer/pepper/url_request_info_util.cc @@ -45,13 +45,12 @@ namespace { // Appends the file ref given the Resource pointer associated with it to the // given HTTP body, returning true on success. -bool AppendFileRefToBody( - PP_Instance instance, - PP_Resource resource, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time, - WebHTTPBody *http_body) { +bool AppendFileRefToBody(PP_Instance instance, + PP_Resource resource, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time, + WebHTTPBody* http_body) { base::FilePath platform_path; PepperPluginInstanceImpl* instance_impl = HostGlobals::Get()->GetInstance(instance); @@ -83,11 +82,10 @@ bool AppendFileRefToBody( default: NOTREACHED(); } - http_body->appendFileRange( - platform_path.AsUTF16Unsafe(), - start_offset, - number_of_bytes, - expected_last_modified_time); + http_body->appendFileRange(platform_path.AsUTF16Unsafe(), + start_offset, + number_of_bytes, + expected_last_modified_time); return true; } @@ -98,7 +96,7 @@ bool ValidateURLRequestData(const URLRequestInfoData& data) { if (data.prefetch_buffer_lower_threshold < 0 || data.prefetch_buffer_upper_threshold < 0 || data.prefetch_buffer_upper_threshold <= - data.prefetch_buffer_lower_threshold) { + data.prefetch_buffer_lower_threshold) { return false; } return true; @@ -117,8 +115,7 @@ bool CreateWebURLRequest(PP_Instance instance, return false; dest->initialize(); - dest->setURL(frame->document().completeURL(WebString::fromUTF8( - data->url))); + dest->setURL(frame->document().completeURL(WebString::fromUTF8(data->url))); dest->setDownloadToFile(data->stream_to_file); dest->setReportUploadProgress(data->record_upload_progress); @@ -131,9 +128,8 @@ bool CreateWebURLRequest(PP_Instance instance, if (!headers.empty()) { net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n\r"); while (it.GetNext()) { - dest->addHTTPHeaderField( - WebString::fromUTF8(it.name()), - WebString::fromUTF8(it.values())); + dest->addHTTPHeaderField(WebString::fromUTF8(it.name()), + WebString::fromUTF8(it.values())); } } @@ -187,11 +183,10 @@ bool CreateWebURLRequest(PP_Instance instance, } bool URLRequestRequiresUniversalAccess(const URLRequestInfoData& data) { - return - data.has_custom_referrer_url || - data.has_custom_content_transfer_encoding || - data.has_custom_user_agent || - url_util::FindAndCompareScheme(data.url, "javascript", NULL); + return data.has_custom_referrer_url || + data.has_custom_content_transfer_encoding || + data.has_custom_user_agent || + url_util::FindAndCompareScheme(data.url, "javascript", NULL); } } // namespace content diff --git a/content/renderer/pepper/url_response_info_util.cc b/content/renderer/pepper/url_response_info_util.cc index 9df6534..2636e19 100644 --- a/content/renderer/pepper/url_response_info_util.cc +++ b/content/renderer/pepper/url_response_info_util.cc @@ -43,9 +43,7 @@ class HeaderFlattener : public WebHTTPHeaderVisitor { std::string buffer_; }; -bool IsRedirect(int32_t status) { - return status >= 300 && status <= 399; -} +bool IsRedirect(int32_t status) { return status >= 300 && status <= 399; } void DidCreateResourceHosts(const ppapi::URLResponseInfoData& in_data, const base::FilePath& external_path, @@ -60,11 +58,11 @@ void DidCreateResourceHosts(const ppapi::URLResponseInfoData& in_data, ppapi::URLResponseInfoData data = in_data; - data.body_as_file_ref = ppapi::MakeExternalFileRefCreateInfo( - external_path, - std::string(), - browser_pending_host_id, - renderer_pending_host_id); + data.body_as_file_ref = + ppapi::MakeExternalFileRefCreateInfo(external_path, + std::string(), + browser_pending_host_id, + renderer_pending_host_id); callback.Run(data); } @@ -79,8 +77,8 @@ void DataFromWebURLResponse(RendererPpapiHostImpl* host_impl, data.status_code = response.httpStatusCode(); data.status_text = response.httpStatusText().utf8(); if (IsRedirect(data.status_code)) { - data.redirect_url = response.httpHeaderField( - WebString::fromUTF8("Location")).utf8(); + data.redirect_url = + response.httpHeaderField(WebString::fromUTF8("Location")).utf8(); } HeaderFlattener flattener; @@ -100,18 +98,16 @@ void DataFromWebURLResponse(RendererPpapiHostImpl* host_impl, std::vector<IPC::Message> create_msgs; create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(external_path)); - host_impl->CreateBrowserResourceHosts( - pp_instance, - create_msgs, - base::Bind(&DidCreateResourceHosts, - data, - external_path, - renderer_pending_host_id, - callback)); + host_impl->CreateBrowserResourceHosts(pp_instance, + create_msgs, + base::Bind(&DidCreateResourceHosts, + data, + external_path, + renderer_pending_host_id, + callback)); } else { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(callback, data)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, data)); } } diff --git a/content/renderer/pepper/v8_var_converter.cc b/content/renderer/pepper/v8_var_converter.cc index 1affa20..6dc5d78 100644 --- a/content/renderer/pepper/v8_var_converter.cc +++ b/content/renderer/pepper/v8_var_converter.cc @@ -54,14 +54,10 @@ namespace BASE_HASH_NAMESPACE { #if defined(COMPILER_GCC) template <> struct hash<HashedHandle> { - size_t operator()(const HashedHandle& handle) const { - return handle.hash(); - } + size_t operator()(const HashedHandle& handle) const { return handle.hash(); } }; #elif defined(COMPILER_MSVC) -inline size_t hash_value(const HashedHandle& handle) { - return handle.hash(); -} +inline size_t hash_value(const HashedHandle& handle) { return handle.hash(); } #endif } // namespace BASE_HASH_NAMESPACE @@ -110,9 +106,8 @@ bool GetOrCreateV8Value(v8::Handle<v8::Context> context, *result = v8::Null(isolate); break; case PP_VARTYPE_BOOL: - *result = (var.value.as_bool == PP_TRUE) - ? v8::True(isolate) - : v8::False(isolate); + *result = (var.value.as_bool == PP_TRUE) ? v8::True(isolate) + : v8::False(isolate); break; case PP_VARTYPE_INT32: *result = v8::Integer::New(isolate, var.value.as_int); @@ -132,10 +127,8 @@ bool GetOrCreateV8Value(v8::Handle<v8::Context> context, // in the sense that string primitives in JavaScript can't be referenced // in the same way that string vars can in pepper. But that information // isn't very useful and primitive strings are a more expected form in JS. - *result = v8::String::NewFromUtf8(isolate, - value.c_str(), - v8::String::kNormalString, - value.size()); + *result = v8::String::NewFromUtf8( + isolate, value.c_str(), v8::String::kNormalString, value.size()); break; } case PP_VARTYPE_ARRAY_BUFFER: { @@ -196,8 +189,8 @@ bool GetOrCreateVar(v8::Handle<v8::Value> val, if (parent_handles->count(HashedHandle(val->ToObject())) != 0) return false; - HandleVarMap::const_iterator it = visited_handles->find( - HashedHandle(val->ToObject())); + HandleVarMap::const_iterator it = + visited_handles->find(HashedHandle(val->ToObject())); if (it != visited_handles->end()) { *result = it->second.get(); return true; @@ -223,13 +216,13 @@ bool GetOrCreateVar(v8::Handle<v8::Value> val, scoped_ptr<blink::WebArrayBuffer> web_array_buffer( blink::WebArrayBufferConverter::createFromV8Value(val)); if (web_array_buffer.get()) { - scoped_refptr<HostArrayBufferVar> buffer_var(new HostArrayBufferVar( - *web_array_buffer)); + scoped_refptr<HostArrayBufferVar> buffer_var( + new HostArrayBufferVar(*web_array_buffer)); *result = buffer_var->GetPPVar(); } else { bool was_resource; - if (!resource_converter->FromV8Value(val->ToObject(), context, result, - &was_resource)) + if (!resource_converter->FromV8Value( + val->ToObject(), context, result, &was_resource)) return false; if (!was_resource) { *result = (new DictionaryVar())->GetPPVar(); @@ -244,9 +237,9 @@ bool GetOrCreateVar(v8::Handle<v8::Value> val, *did_create = true; if (val->IsObject() || val->IsString()) { - visited_handles->insert(make_pair( - HashedHandle(val->ToObject()), - ScopedPPVar(ScopedPPVar::PassRef(), *result))); + visited_handles->insert( + make_pair(HashedHandle(val->ToObject()), + ScopedPPVar(ScopedPPVar::PassRef(), *result))); } return true; } @@ -263,15 +256,12 @@ V8VarConverter::V8VarConverter(PP_Instance instance) instance, RendererPpapiHost::GetForPPInstance(instance))); } -V8VarConverter::V8VarConverter( - PP_Instance instance, - scoped_ptr<ResourceConverter> resource_converter) +V8VarConverter::V8VarConverter(PP_Instance instance, + scoped_ptr<ResourceConverter> resource_converter) : message_loop_proxy_(base::MessageLoopProxy::current()), - resource_converter_(resource_converter.release()) { -} + resource_converter_(resource_converter.release()) {} -V8VarConverter::~V8VarConverter() { -} +V8VarConverter::~V8VarConverter() {} // To/FromV8Value use a stack-based DFS search to traverse V8/Var graph. Each // iteration, the top node on the stack examined. If the node has not been @@ -312,8 +302,12 @@ bool V8VarConverter::ToV8Value(const PP_Var& var, } bool did_create = false; - if (!GetOrCreateV8Value(context, current_var, ¤t_v8, &did_create, - &visited_ids, &parent_ids, + if (!GetOrCreateV8Value(context, + current_var, + ¤t_v8, + &did_create, + &visited_ids, + &parent_ids, resource_converter_.get())) { return false; } @@ -337,8 +331,12 @@ bool V8VarConverter::ToV8Value(const PP_Var& var, for (size_t i = 0; i < array_var->elements().size(); ++i) { const PP_Var& child_var = array_var->elements()[i].get(); v8::Handle<v8::Value> child_v8; - if (!GetOrCreateV8Value(context, child_var, &child_v8, &did_create, - &visited_ids, &parent_ids, + if (!GetOrCreateV8Value(context, + child_var, + &child_v8, + &did_create, + &visited_ids, + &parent_ids, resource_converter_.get())) { return false; } @@ -368,22 +366,25 @@ bool V8VarConverter::ToV8Value(const PP_Var& var, const std::string& key = iter->first; const PP_Var& child_var = iter->second.get(); v8::Handle<v8::Value> child_v8; - if (!GetOrCreateV8Value(context, child_var, &child_v8, &did_create, - &visited_ids, &parent_ids, + if (!GetOrCreateV8Value(context, + child_var, + &child_v8, + &did_create, + &visited_ids, + &parent_ids, resource_converter_.get())) { return false; } if (did_create && CanHaveChildren(child_var)) stack.push(child_var); v8::TryCatch try_catch; - v8_object->Set(v8::String::NewFromUtf8(isolate, - key.c_str(), - v8::String::kNormalString, - key.length()), - child_v8); + v8_object->Set( + v8::String::NewFromUtf8( + isolate, key.c_str(), v8::String::kNormalString, key.length()), + child_v8); if (try_catch.HasCaught()) { LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " - << "exception."; + << "exception."; return false; } } @@ -423,10 +424,15 @@ void V8VarConverter::FromV8Value( } bool did_create = false; - if (!GetOrCreateVar(current_v8, context, ¤t_var, &did_create, - &visited_handles, &parent_handles, + if (!GetOrCreateVar(current_v8, + context, + ¤t_var, + &did_create, + &visited_handles, + &parent_handles, resource_converter_.get())) { - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -445,7 +451,8 @@ void V8VarConverter::FromV8Value( ArrayVar* array_var = ArrayVar::FromPPVar(current_var); if (!array_var) { NOTREACHED(); - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -454,7 +461,8 @@ void V8VarConverter::FromV8Value( v8::TryCatch try_catch; v8::Handle<v8::Value> child_v8 = v8_array->Get(i); if (try_catch.HasCaught()) { - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -463,10 +471,15 @@ void V8VarConverter::FromV8Value( continue; PP_Var child_var; - if (!GetOrCreateVar(child_v8, context, &child_var, &did_create, - &visited_handles, &parent_handles, + if (!GetOrCreateVar(child_v8, + context, + &child_var, + &did_create, + &visited_handles, + &parent_handles, resource_converter_.get())) { - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -483,7 +496,8 @@ void V8VarConverter::FromV8Value( DictionaryVar* dict_var = DictionaryVar::FromPPVar(current_var); if (!dict_var) { NOTREACHED(); - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -494,9 +508,11 @@ void V8VarConverter::FromV8Value( // Extend this test to cover more types as necessary and if sensible. if (!key->IsString() && !key->IsNumber()) { - NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) << "\" " + NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) + << "\" " "is neither a string nor a number"; - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } @@ -510,16 +526,22 @@ void V8VarConverter::FromV8Value( v8::TryCatch try_catch; v8::Handle<v8::Value> child_v8 = v8_object->Get(key); if (try_catch.HasCaught()) { - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } PP_Var child_var; - if (!GetOrCreateVar(child_v8, context, &child_var, &did_create, - &visited_handles, &parent_handles, + if (!GetOrCreateVar(child_v8, + context, + &child_var, + &did_create, + &visited_handles, + &parent_handles, resource_converter_.get())) { - message_loop_proxy_->PostTask(FROM_HERE, + message_loop_proxy_->PostTask( + FROM_HERE, base::Bind(callback, ScopedPPVar(PP_MakeUndefined()), false)); return; } diff --git a/content/renderer/pepper/v8_var_converter.h b/content/renderer/pepper/v8_var_converter.h index 37ce208..8bb22b7 100644 --- a/content/renderer/pepper/v8_var_converter.h +++ b/content/renderer/pepper/v8_var_converter.h @@ -5,7 +5,6 @@ #ifndef CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H #define CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H - #include "base/basictypes.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -27,9 +26,8 @@ class CONTENT_EXPORT V8VarConverter { public: explicit V8VarConverter(PP_Instance instance); // Constructor for testing. - V8VarConverter( - PP_Instance instance, - scoped_ptr<ResourceConverter> resource_converter); + V8VarConverter(PP_Instance instance, + scoped_ptr<ResourceConverter> resource_converter); ~V8VarConverter(); // Converts the given PP_Var to a v8::Value. True is returned upon success. diff --git a/content/renderer/pepper/v8_var_converter_unittest.cc b/content/renderer/pepper/v8_var_converter_unittest.cc index 7c254f1..95d5843 100644 --- a/content/renderer/pepper/v8_var_converter_unittest.cc +++ b/content/renderer/pepper/v8_var_converter_unittest.cc @@ -82,13 +82,13 @@ bool Equals(const PP_Var& var, return var.type == PP_VARTYPE_NULL; } else if (val->IsBoolean() || val->IsBooleanObject()) { return var.type == PP_VARTYPE_BOOL && - PP_FromBool(val->ToBoolean()->Value()) == var.value.as_bool; + PP_FromBool(val->ToBoolean()->Value()) == var.value.as_bool; } else if (val->IsInt32()) { return var.type == PP_VARTYPE_INT32 && - val->ToInt32()->Value() == var.value.as_int; + val->ToInt32()->Value() == var.value.as_int; } else if (val->IsNumber() || val->IsNumberObject()) { return var.type == PP_VARTYPE_DOUBLE && - fabs(val->ToNumber()->Value() - var.value.as_double) <= 1.0e-4; + fabs(val->ToNumber()->Value() - var.value.as_double) <= 1.0e-4; } else if (val->IsString() || val->IsStringObject()) { if (var.type != PP_VARTYPE_STRING) return false; @@ -133,8 +133,8 @@ bool Equals(const PP_Var& var, v8::String::Utf8Value name_utf8(key->ToString()); ScopedPPVar release_key(ScopedPPVar::PassRef(), - StringVar::StringToPPVar( - std::string(*name_utf8, name_utf8.length()))); + StringVar::StringToPPVar(std::string( + *name_utf8, name_utf8.length()))); if (!dict_var->HasKey(release_key.get())) return false; ScopedPPVar release_value(ScopedPPVar::PassRef(), @@ -148,8 +148,7 @@ bool Equals(const PP_Var& var, return false; } -bool Equals(const PP_Var& var, - v8::Handle<v8::Value> val) { +bool Equals(const PP_Var& var, v8::Handle<v8::Value> val) { VarHandleMap var_handle_map; return Equals(var, val, &var_handle_map); } @@ -157,8 +156,7 @@ bool Equals(const PP_Var& var, class V8VarConverterTest : public testing::Test { public: V8VarConverterTest() - : isolate_(v8::Isolate::GetCurrent()), - conversion_success_(false) { + : isolate_(v8::Isolate::GetCurrent()), conversion_success_(false) { PP_Instance dummy = 1234; converter_.reset(new V8VarConverter( dummy, @@ -184,9 +182,11 @@ class V8VarConverterTest : public testing::Test { v8::Handle<v8::Context> context, PP_Var* result) { base::RunLoop loop; - converter_->FromV8Value(val, context, base::Bind( - &V8VarConverterTest::FromV8ValueComplete, base::Unretained(this), - loop.QuitClosure())); + converter_->FromV8Value(val, + context, + base::Bind(&V8VarConverterTest::FromV8ValueComplete, + base::Unretained(this), + loop.QuitClosure())); loop.Run(); if (conversion_success_) *result = conversion_result_; @@ -281,8 +281,8 @@ TEST_F(V8VarConverterTest, DictionaryArrayRoundTripTest) { EXPECT_TRUE(RoundTripAndCompare(array->GetPPVar())); // Array with 2 references to the same string. - ScopedPPVar release_string( - ScopedPPVar::PassRef(), StringVar::StringToPPVar("abc")); + ScopedPPVar release_string(ScopedPPVar::PassRef(), + StringVar::StringToPPVar("abc")); array->Set(index++, release_string.get()); array->Set(index++, release_string.get()); EXPECT_TRUE(RoundTripAndCompare(array->GetPPVar())); @@ -353,8 +353,8 @@ TEST_F(V8VarConverterTest, Cycles) { // Array <-> dictionary cycle. dictionary->SetWithStringKey("1", release_array.get()); - ASSERT_FALSE(converter_->ToV8Value(release_dictionary.get(), - context, &v8_result)); + ASSERT_FALSE( + converter_->ToV8Value(release_dictionary.get(), context, &v8_result)); // Break the cycle. // TODO(raymes): We need some better machinery for releasing vars with // cycles. Remove the code below once we have that. @@ -362,8 +362,8 @@ TEST_F(V8VarConverterTest, Cycles) { // Array with self reference. array->Set(0, release_array.get()); - ASSERT_FALSE(converter_->ToV8Value(release_array.get(), - context, &v8_result)); + ASSERT_FALSE( + converter_->ToV8Value(release_array.get(), context, &v8_result)); // Break the self reference. array->Set(0, PP_MakeUndefined()); } @@ -407,14 +407,15 @@ TEST_F(V8VarConverterTest, StrangeDictionaryKeyTest) { v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - const char* source = "(function() {" + const char* source = + "(function() {" "return {" - "1: 'foo'," - "'2': 'bar'," - "true: 'baz'," - "false: 'qux'," - "null: 'quux'," - "undefined: 'oops'" + "1: 'foo'," + "'2': 'bar'," + "true: 'baz'," + "false: 'qux'," + "null: 'quux'," + "undefined: 'oops'" "};" "})();"; @@ -424,8 +425,8 @@ TEST_F(V8VarConverterTest, StrangeDictionaryKeyTest) { ASSERT_FALSE(object.IsEmpty()); PP_Var actual; - ASSERT_TRUE(FromV8ValueSync(object, - v8::Local<v8::Context>::New(isolate_, context_), &actual)); + ASSERT_TRUE(FromV8ValueSync( + object, v8::Local<v8::Context>::New(isolate_, context_), &actual)); ScopedPPVar release_actual(ScopedPPVar::PassRef(), actual); scoped_refptr<DictionaryVar> expected(new DictionaryVar); @@ -441,8 +442,7 @@ TEST_F(V8VarConverterTest, StrangeDictionaryKeyTest) { expected->SetWithStringKey("null", quux.get()); ScopedPPVar oops(ScopedPPVar::PassRef(), StringVar::StringToPPVar("oops")); expected->SetWithStringKey("undefined", oops.get()); - ScopedPPVar release_expected( - ScopedPPVar::PassRef(), expected->GetPPVar()); + ScopedPPVar release_expected(ScopedPPVar::PassRef(), expected->GetPPVar()); ASSERT_TRUE(TestEqual(release_expected.get(), release_actual.get(), true)); } |