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

Side by Side Diff: webkit/glue/plugins/webplugin_delegate_impl_win.cc

Issue 2897002: Page cycler tests failed on Vista because our windowless plugin code fails to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
6 6
7 #include <map>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/iat_patch.h" 12 #include "base/iat_patch.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/registry.h" 15 #include "base/registry.h"
15 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
16 #include "base/stats_counters.h" 17 #include "base/stats_counters.h"
(...skipping 13 matching lines...) Expand all
30 using WebKit::WebCursorInfo; 31 using WebKit::WebCursorInfo;
31 using WebKit::WebKeyboardEvent; 32 using WebKit::WebKeyboardEvent;
32 using WebKit::WebInputEvent; 33 using WebKit::WebInputEvent;
33 using WebKit::WebMouseEvent; 34 using WebKit::WebMouseEvent;
34 35
35 namespace { 36 namespace {
36 37
37 const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty"; 38 const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty";
38 const wchar_t kPluginNameAtomProperty[] = L"PluginNameAtom"; 39 const wchar_t kPluginNameAtomProperty[] = L"PluginNameAtom";
39 const wchar_t kDummyActivationWindowName[] = L"DummyWindowForActivation"; 40 const wchar_t kDummyActivationWindowName[] = L"DummyWindowForActivation";
40 const wchar_t kPluginOrigProc[] = L"OriginalPtr";
41 const wchar_t kPluginFlashThrottle[] = L"FlashThrottle"; 41 const wchar_t kPluginFlashThrottle[] = L"FlashThrottle";
42 42
43 // The fastest we are willing to process WM_USER+1 events for Flash. 43 // The fastest we are willing to process WM_USER+1 events for Flash.
44 // Flash can easily exceed the limits of our CPU if we don't throttle it. 44 // Flash can easily exceed the limits of our CPU if we don't throttle it.
45 // The throttle has been chosen by testing various delays and compromising 45 // The throttle has been chosen by testing various delays and compromising
46 // on acceptable Flash performance and reasonable CPU consumption. 46 // on acceptable Flash performance and reasonable CPU consumption.
47 // 47 //
48 // I'd like to make the throttle delay variable, based on the amount of 48 // I'd like to make the throttle delay variable, based on the amount of
49 // time currently required to paint Flash plugins. There isn't a good 49 // time currently required to paint Flash plugins. There isn't a good
50 // way to count the time spent in aggregate plugin painting, however, so 50 // way to count the time spent in aggregate plugin painting, however, so
51 // this seems to work well enough. 51 // this seems to work well enough.
52 const int kFlashWMUSERMessageThrottleDelayMs = 5; 52 const int kFlashWMUSERMessageThrottleDelayMs = 5;
53 53
54 // Flash displays popups in response to user clicks by posting a WM_USER 54 // Flash displays popups in response to user clicks by posting a WM_USER
55 // message to the plugin window. The handler for this message displays 55 // message to the plugin window. The handler for this message displays
56 // the popup. To ensure that the popups allowed state is sent correctly 56 // the popup. To ensure that the popups allowed state is sent correctly
57 // to the renderer we reset the popups allowed state in a timer. 57 // to the renderer we reset the popups allowed state in a timer.
58 const int kWindowedPluginPopupTimerMs = 50; 58 const int kWindowedPluginPopupTimerMs = 50;
59 59
60 // The current instance of the plugin which entered the modal loop. 60 // The current instance of the plugin which entered the modal loop.
61 WebPluginDelegateImpl* g_current_plugin_instance = NULL; 61 WebPluginDelegateImpl* g_current_plugin_instance = NULL;
62 62
63 typedef std::deque<MSG> ThrottleQueue; 63 typedef std::deque<MSG> ThrottleQueue;
64 base::LazyInstance<ThrottleQueue> g_throttle_queue(base::LINKER_INITIALIZED); 64 base::LazyInstance<ThrottleQueue> g_throttle_queue(base::LINKER_INITIALIZED);
65 base::LazyInstance<std::map<HWND, WNDPROC> > g_window_handle_proc_map(
66 base::LINKER_INITIALIZED);
67
65 68
66 // Helper object for patching the TrackPopupMenu API. 69 // Helper object for patching the TrackPopupMenu API.
67 base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_track_popup_menu( 70 base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_track_popup_menu(
68 base::LINKER_INITIALIZED); 71 base::LINKER_INITIALIZED);
69 72
70 // Helper object for patching the SetCursor API. 73 // Helper object for patching the SetCursor API.
71 base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor( 74 base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor(
72 base::LINKER_INITIALIZED); 75 base::LINKER_INITIALIZED);
73 76
74 // Helper object for patching the RegEnumKeyExW API. 77 // Helper object for patching the RegEnumKeyExW API.
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 kFlashWMUSERMessageThrottleDelayMs); 640 kFlashWMUSERMessageThrottleDelayMs);
638 } 641 }
639 } 642 }
640 643
641 // We go out of our way to find the hidden windows created by Flash for 644 // We go out of our way to find the hidden windows created by Flash for
642 // windowless plugins. We throttle the rate at which they deliver messages 645 // windowless plugins. We throttle the rate at which they deliver messages
643 // so that they will not consume outrageous amounts of CPU. 646 // so that they will not consume outrageous amounts of CPU.
644 // static 647 // static
645 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, 648 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd,
646 UINT message, WPARAM wparam, LPARAM lparam) { 649 UINT message, WPARAM wparam, LPARAM lparam) {
647 WNDPROC old_proc = reinterpret_cast<WNDPROC>(GetProp(hwnd, kPluginOrigProc)); 650 std::map<HWND, WNDPROC>::iterator index =
651 g_window_handle_proc_map.Get().find(hwnd);
652
653 WNDPROC old_proc = (*index).second;
648 DCHECK(old_proc); 654 DCHECK(old_proc);
649 655
650 switch (message) { 656 switch (message) {
651 case WM_NCDESTROY: { 657 case WM_NCDESTROY: {
652 WebPluginDelegateImpl::ClearThrottleQueueForWindow(hwnd); 658 WebPluginDelegateImpl::ClearThrottleQueueForWindow(hwnd);
659 g_window_handle_proc_map.Get().erase(index);
653 break; 660 break;
654 } 661 }
655 // Flash may flood the message queue with WM_USER+1 message causing 100% CPU 662 // Flash may flood the message queue with WM_USER+1 message causing 100% CPU
656 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We 663 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We
657 // prevent this by throttling the messages. 664 // prevent this by throttling the messages.
658 case WM_USER + 1: { 665 case WM_USER + 1: {
659 WebPluginDelegateImpl::ThrottleMessage(old_proc, hwnd, message, wparam, 666 WebPluginDelegateImpl::ThrottleMessage(old_proc, hwnd, message, wparam,
660 lparam); 667 lparam);
661 return TRUE; 668 return TRUE;
662 } 669 }
(...skipping 17 matching lines...) Expand all
680 if (wcscmp(class_name, L"SWFlash_PlaceholderX")) 687 if (wcscmp(class_name, L"SWFlash_PlaceholderX"))
681 return TRUE; 688 return TRUE;
682 689
683 WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>( 690 WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>(
684 GetWindowLongPtr(window, GWLP_WNDPROC)); 691 GetWindowLongPtr(window, GWLP_WNDPROC));
685 if (current_wnd_proc != wnd_proc) { 692 if (current_wnd_proc != wnd_proc) {
686 WNDPROC old_flash_proc = reinterpret_cast<WNDPROC>(SetWindowLongPtr( 693 WNDPROC old_flash_proc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(
687 window, GWLP_WNDPROC, 694 window, GWLP_WNDPROC,
688 reinterpret_cast<LONG>(wnd_proc))); 695 reinterpret_cast<LONG>(wnd_proc)));
689 DCHECK(old_flash_proc); 696 DCHECK(old_flash_proc);
690 BOOL result = SetProp(window, kPluginOrigProc, old_flash_proc); 697 g_window_handle_proc_map.Get()[window] = old_flash_proc;
691 if (!result) {
692 LOG(ERROR) << "SetProp failed, last error = " << GetLastError();
693 return FALSE;
694 }
695 } 698 }
696 699
697 return TRUE; 700 return TRUE;
698 } 701 }
699 702
700 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { 703 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() {
701 DCHECK(!dummy_window_for_activation_); 704 DCHECK(!dummy_window_for_activation_);
702 dummy_window_for_activation_ = CreateWindowEx( 705 dummy_window_for_activation_ = CreateWindowEx(
703 0, 706 0,
704 L"Static", 707 L"Static",
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 case WM_LBUTTONUP: 1390 case WM_LBUTTONUP:
1388 case WM_MBUTTONUP: 1391 case WM_MBUTTONUP:
1389 case WM_RBUTTONUP: 1392 case WM_RBUTTONUP:
1390 ::ReleaseCapture(); 1393 ::ReleaseCapture();
1391 break; 1394 break;
1392 1395
1393 default: 1396 default:
1394 break; 1397 break;
1395 } 1398 }
1396 } 1399 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698