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

Side by Side Diff: base/win/object_watcher.cc

Issue 10535041: Log stack trace when ObjectWatcher::StartWatching() is called. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « base/win/object_watcher.h ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/win/object_watcher.h" 5 #include "base/win/object_watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/alias.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 10
10 namespace base { 11 namespace base {
11 namespace win { 12 namespace win {
12 13
13 //----------------------------------------------------------------------------- 14 //-----------------------------------------------------------------------------
14 15
15 ObjectWatcher::ObjectWatcher() 16 ObjectWatcher::ObjectWatcher()
16 : weak_factory_(this), 17 : weak_factory_(this),
17 object_(NULL), 18 object_(NULL),
(...skipping 15 matching lines...) Expand all
33 // Since our job is to just notice when an object is signaled and report the 34 // Since our job is to just notice when an object is signaled and report the
34 // result back to this thread, we can just run on a Windows wait thread. 35 // result back to this thread, we can just run on a Windows wait thread.
35 DWORD wait_flags = WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE; 36 DWORD wait_flags = WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE;
36 37
37 // DoneWaiting can be synchronously called from RegisterWaitForSingleObject, 38 // DoneWaiting can be synchronously called from RegisterWaitForSingleObject,
38 // so set up all state now. 39 // so set up all state now.
39 callback_ = base::Bind(&ObjectWatcher::Signal, weak_factory_.GetWeakPtr(), 40 callback_ = base::Bind(&ObjectWatcher::Signal, weak_factory_.GetWeakPtr(),
40 delegate); 41 delegate);
41 object_ = object; 42 object_ = object;
42 origin_loop_ = MessageLoop::current(); 43 origin_loop_ = MessageLoop::current();
44 stack_trace_ = base::debug::StackTrace();
43 45
44 if (!RegisterWaitForSingleObject(&wait_object_, object, DoneWaiting, 46 if (!RegisterWaitForSingleObject(&wait_object_, object, DoneWaiting,
45 this, INFINITE, wait_flags)) { 47 this, INFINITE, wait_flags)) {
46 NOTREACHED() << "RegisterWaitForSingleObject failed: " << GetLastError(); 48 NOTREACHED() << "RegisterWaitForSingleObject failed: " << GetLastError();
47 object_ = NULL; 49 object_ = NULL;
48 wait_object_ = NULL; 50 wait_object_ = NULL;
49 return false; 51 return false;
50 } 52 }
51 53
52 // We need to know if the current message loop is going away so we can 54 // We need to know if the current message loop is going away so we can
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ObjectWatcher* that = static_cast<ObjectWatcher*>(param); 92 ObjectWatcher* that = static_cast<ObjectWatcher*>(param);
91 that->origin_loop_->PostTask(FROM_HERE, that->callback_); 93 that->origin_loop_->PostTask(FROM_HERE, that->callback_);
92 that->callback_.Reset(); 94 that->callback_.Reset();
93 } 95 }
94 96
95 void ObjectWatcher::Signal(Delegate* delegate) { 97 void ObjectWatcher::Signal(Delegate* delegate) {
96 // Signaling the delegate may result in our destruction or a nested call to 98 // Signaling the delegate may result in our destruction or a nested call to
97 // StartWatching(). As a result, we save any state we need and clear previous 99 // StartWatching(). As a result, we save any state we need and clear previous
98 // watcher state before signaling the delegate. 100 // watcher state before signaling the delegate.
99 HANDLE object = object_; 101 HANDLE object = object_;
102 // Alias the stack trace where the watch was started so it'll be available in
103 // minidumps.
104 base::debug::StackTrace stack_trace = stack_trace_;
105 base::debug::Alias(&stack_trace);
100 StopWatching(); 106 StopWatching();
101 delegate->OnObjectSignaled(object); 107 delegate->OnObjectSignaled(object);
102 } 108 }
103 109
104 void ObjectWatcher::WillDestroyCurrentMessageLoop() { 110 void ObjectWatcher::WillDestroyCurrentMessageLoop() {
105 // Need to shutdown the watch so that we don't try to access the MessageLoop 111 // Need to shutdown the watch so that we don't try to access the MessageLoop
106 // after this point. 112 // after this point.
107 StopWatching(); 113 StopWatching();
108 } 114 }
109 115
110 } // namespace win 116 } // namespace win
111 } // namespace base 117 } // namespace base
OLDNEW
« no previous file with comments | « base/win/object_watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698