Commit b59e330a authored by thakis's avatar thakis Committed by Commit bot

win: Move HWNDMessageHandler's WeakPtrFactory member to the end.

Fixes some

  [chromium-style] WeakPtrFactory members which refer to their outer class must
  be the last member in the outer class definition.

warnings and also makes the code more correct.

BUG=303818,467287

Review URL: https://codereview.chromium.org/1107353003

Cr-Commit-Position: refs/heads/master@{#327374}
parent 7d1acb93
...@@ -337,7 +337,6 @@ long HWNDMessageHandler::last_touch_message_time_ = 0; ...@@ -337,7 +337,6 @@ long HWNDMessageHandler::last_touch_message_time_ = 0;
HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
fullscreen_handler_(new FullscreenHandler), fullscreen_handler_(new FullscreenHandler),
weak_factory_(this),
waiting_for_close_now_(false), waiting_for_close_now_(false),
remove_standard_frame_(false), remove_standard_frame_(false),
use_system_default_icon_(false), use_system_default_icon_(false),
...@@ -361,7 +360,8 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) ...@@ -361,7 +360,8 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
touch_down_contexts_(0), touch_down_contexts_(0),
last_mouse_hwheel_time_(0), last_mouse_hwheel_time_(0),
msg_handled_(FALSE), msg_handled_(FALSE),
dwm_transition_desired_(false) { dwm_transition_desired_(false),
weak_factory_(this) {
} }
HWNDMessageHandler::~HWNDMessageHandler() { HWNDMessageHandler::~HWNDMessageHandler() {
......
...@@ -55,16 +55,15 @@ const int WM_NCUAHDRAWCAPTION = 0xAE; ...@@ -55,16 +55,15 @@ const int WM_NCUAHDRAWCAPTION = 0xAE;
const int WM_NCUAHDRAWFRAME = 0xAF; const int WM_NCUAHDRAWFRAME = 0xAF;
// IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of // IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of
// BEGIN_MSG_MAP_EX. The main difference is it adds a WeakPtrFactory member // BEGIN_MSG_MAP_EX. The main difference is it uses a WeakPtrFactory member
// (|weak_factory_|) that is used in _ProcessWindowMessage() and changing // (|weak_factory|) that is used in _ProcessWindowMessage() and changing
// IsMsgHandled() from a member function to a define that checks if the weak // IsMsgHandled() from a member function to a define that checks if the weak
// factory is still valid in addition to the member. Together these allow for // factory is still valid in addition to the member. Together these allow for
// |this| to be deleted during dispatch. // |this| to be deleted during dispatch.
#define IsMsgHandled() !ref.get() || msg_handled_ #define IsMsgHandled() !ref.get() || msg_handled_
#define BEGIN_SAFE_MSG_MAP_EX(the_class) \ #define BEGIN_SAFE_MSG_MAP_EX(weak_factory) \
private: \ private: \
base::WeakPtrFactory<the_class> weak_factory_; \
BOOL msg_handled_; \ BOOL msg_handled_; \
\ \
public: \ public: \
...@@ -78,7 +77,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; ...@@ -78,7 +77,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF;
LPARAM l_param, \ LPARAM l_param, \
LRESULT& l_result, \ LRESULT& l_result, \
DWORD msg_map_id = 0) { \ DWORD msg_map_id = 0) { \
base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \ base::WeakPtr<HWNDMessageHandler> ref(weak_factory.GetWeakPtr()); \
BOOL old_msg_handled = msg_handled_; \ BOOL old_msg_handled = msg_handled_; \
BOOL ret = _ProcessWindowMessage(hwnd, msg, w_param, l_param, l_result, \ BOOL ret = _ProcessWindowMessage(hwnd, msg, w_param, l_param, l_result, \
msg_map_id); \ msg_map_id); \
...@@ -92,7 +91,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; ...@@ -92,7 +91,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF;
LPARAM lParam, \ LPARAM lParam, \
LRESULT& lResult, \ LRESULT& lResult, \
DWORD dwMsgMapID) { \ DWORD dwMsgMapID) { \
base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \ base::WeakPtr<HWNDMessageHandler> ref(weak_factory.GetWeakPtr()); \
BOOL bHandled = TRUE; \ BOOL bHandled = TRUE; \
hWnd; \ hWnd; \
uMsg; \ uMsg; \
...@@ -315,7 +314,7 @@ class VIEWS_EXPORT HWNDMessageHandler : ...@@ -315,7 +314,7 @@ class VIEWS_EXPORT HWNDMessageHandler :
// Message Handlers ---------------------------------------------------------- // Message Handlers ----------------------------------------------------------
BEGIN_SAFE_MSG_MAP_EX(HWNDMessageHandler) BEGIN_SAFE_MSG_MAP_EX(weak_factory_)
// Range handlers must go first! // Range handlers must go first!
CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
...@@ -627,6 +626,8 @@ class VIEWS_EXPORT HWNDMessageHandler : ...@@ -627,6 +626,8 @@ class VIEWS_EXPORT HWNDMessageHandler :
// glass. Defaults to false. // glass. Defaults to false.
bool dwm_transition_desired_; bool dwm_transition_desired_;
base::WeakPtrFactory<HWNDMessageHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment