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/browser/automation/automation_resource_tracker.h" | 5 #include "chrome/browser/automation/automation_resource_tracker.h" |
6 | 6 |
7 #include "chrome/common/automation_messages.h" | 7 #include "chrome/common/automation_messages.h" |
8 | 8 |
9 AutomationResourceTrackerImpl::AutomationResourceTrackerImpl( | 9 AutomationResourceTrackerImpl::AutomationResourceTrackerImpl( |
10 IPC::Message::Sender* sender) | 10 IPC::Message::Sender* sender) |
(...skipping 16 matching lines...) Expand all Loading... |
27 AddObserverTypeProxy(resource); | 27 AddObserverTypeProxy(resource); |
28 | 28 |
29 return handle; | 29 return handle; |
30 } | 30 } |
31 | 31 |
32 void AutomationResourceTrackerImpl::RemoveImpl(const void* resource) { | 32 void AutomationResourceTrackerImpl::RemoveImpl(const void* resource) { |
33 if (!ContainsResourceImpl(resource)) | 33 if (!ContainsResourceImpl(resource)) |
34 return; | 34 return; |
35 | 35 |
36 int handle = resource_to_handle_[resource]; | 36 int handle = resource_to_handle_[resource]; |
37 DCHECK(handle_to_resource_[handle] == resource); | 37 DCHECK_EQ(handle_to_resource_[handle], resource); |
38 | 38 |
39 RemoveObserverTypeProxy(resource); | 39 RemoveObserverTypeProxy(resource); |
40 | 40 |
41 resource_to_handle_.erase(resource); | 41 resource_to_handle_.erase(resource); |
42 handle_to_resource_.erase(handle); | 42 handle_to_resource_.erase(handle); |
43 } | 43 } |
44 | 44 |
45 int AutomationResourceTrackerImpl::GenerateHandle() { | 45 int AutomationResourceTrackerImpl::GenerateHandle() { |
46 static int handle = 0; | 46 static int handle = 0; |
47 return ++handle; | 47 return ++handle; |
(...skipping 27 matching lines...) Expand all Loading... |
75 void AutomationResourceTrackerImpl::HandleCloseNotification( | 75 void AutomationResourceTrackerImpl::HandleCloseNotification( |
76 const void* resource) { | 76 const void* resource) { |
77 if (!ContainsResourceImpl(resource)) | 77 if (!ContainsResourceImpl(resource)) |
78 return; | 78 return; |
79 | 79 |
80 sender_->Send( | 80 sender_->Send( |
81 new AutomationMsg_InvalidateHandle(resource_to_handle_[resource])); | 81 new AutomationMsg_InvalidateHandle(resource_to_handle_[resource])); |
82 | 82 |
83 RemoveImpl(resource); | 83 RemoveImpl(resource); |
84 } | 84 } |
OLD | NEW |