OLD | NEW |
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 "chrome/test/automation/automation_handle_tracker.h" | 5 #include "chrome/test/automation/automation_handle_tracker.h" |
6 | 6 |
7 #include "chrome/test/automation/automation_messages.h" | 7 #include "chrome/test/automation/automation_messages.h" |
8 #include "chrome/test/automation/automation_proxy.h" | 8 #include "chrome/test/automation/automation_proxy.h" |
9 | 9 |
10 AutomationResourceProxy::AutomationResourceProxy( | 10 AutomationResourceProxy::AutomationResourceProxy( |
11 AutomationHandleTracker* tracker, AutomationMessageSender* sender, | 11 AutomationHandleTracker* tracker, AutomationMessageSender* sender, |
12 AutomationHandle handle) | 12 AutomationHandle handle) |
13 : handle_(handle), | 13 : handle_(handle), |
14 tracker_(tracker), | 14 tracker_(tracker), |
15 sender_(sender), | 15 sender_(sender), |
16 is_valid_(true) { | 16 is_valid_(true) { |
17 tracker_->Add(this); | 17 tracker_->Add(this); |
18 } | 18 } |
19 | 19 |
20 AutomationResourceProxy::~AutomationResourceProxy() { | 20 AutomationResourceProxy::~AutomationResourceProxy() { |
21 if (tracker_) | 21 if (tracker_) |
22 tracker_->Remove(this); | 22 tracker_->Remove(this); |
23 } | 23 } |
24 | 24 |
| 25 AutomationHandleTracker::AutomationHandleTracker() : channel_(NULL) {} |
| 26 |
25 AutomationHandleTracker::~AutomationHandleTracker() { | 27 AutomationHandleTracker::~AutomationHandleTracker() { |
26 // Tell any live objects that the tracker is going away so they don't try to | 28 // Tell any live objects that the tracker is going away so they don't try to |
27 // call us when they are being destroyed. | 29 // call us when they are being destroyed. |
28 for (HandleToObjectMap::iterator iter = handle_to_object_.begin(); | 30 for (HandleToObjectMap::iterator iter = handle_to_object_.begin(); |
29 iter != handle_to_object_.end(); ++iter) { | 31 iter != handle_to_object_.end(); ++iter) { |
30 iter->second->Invalidate(); | 32 iter->second->Invalidate(); |
31 } | 33 } |
32 } | 34 } |
33 | 35 |
34 void AutomationHandleTracker::Add(AutomationResourceProxy* proxy) { | 36 void AutomationHandleTracker::Add(AutomationResourceProxy* proxy) { |
(...skipping 26 matching lines...) Expand all Loading... |
61 AutomationResourceProxy* AutomationHandleTracker::GetResource( | 63 AutomationResourceProxy* AutomationHandleTracker::GetResource( |
62 AutomationHandle handle) { | 64 AutomationHandle handle) { |
63 AutoLock lock(map_lock_); | 65 AutoLock lock(map_lock_); |
64 HandleToObjectMap::iterator iter = handle_to_object_.find(handle); | 66 HandleToObjectMap::iterator iter = handle_to_object_.find(handle); |
65 if (iter == handle_to_object_.end()) | 67 if (iter == handle_to_object_.end()) |
66 return NULL; | 68 return NULL; |
67 | 69 |
68 iter->second->AddRef(); | 70 iter->second->AddRef(); |
69 return iter->second; | 71 return iter->second; |
70 } | 72 } |
OLD | NEW |