OLD | NEW |
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 "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 | 990 |
991 AliveV8PermissionRequestItem* new_item = | 991 AliveV8PermissionRequestItem* new_item = |
992 new std::pair<int, base::WeakPtr<BrowserPlugin> >( | 992 new std::pair<int, base::WeakPtr<BrowserPlugin> >( |
993 id, weak_ptr_factory_.GetWeakPtr()); | 993 id, weak_ptr_factory_.GetWeakPtr()); |
994 | 994 |
995 std::pair<std::map<int, AliveV8PermissionRequestItem*>::iterator, bool> | 995 std::pair<std::map<int, AliveV8PermissionRequestItem*>::iterator, bool> |
996 result = alive_v8_permission_request_objects_.insert( | 996 result = alive_v8_permission_request_objects_.insert( |
997 std::make_pair(id, new_item)); | 997 std::make_pair(id, new_item)); |
998 CHECK(result.second); // Inserted in the map. | 998 CHECK(result.second); // Inserted in the map. |
999 AliveV8PermissionRequestItem* request_item = result.first->second; | 999 AliveV8PermissionRequestItem* request_item = result.first->second; |
1000 weak_request.MakeWeak(isolate, request_item, WeakCallbackForPersistObject); | 1000 weak_request.MakeWeak( |
| 1001 isolate, static_cast<void*>(request_item), WeakCallbackForPersistObject); |
1001 } | 1002 } |
1002 | 1003 |
1003 // static | 1004 // static |
1004 void BrowserPlugin::WeakCallbackForPersistObject( | 1005 void BrowserPlugin::WeakCallbackForPersistObject( |
1005 v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* param) { | 1006 v8::Isolate* isolate, v8::Persistent<v8::Value>* object, void* param) { |
1006 v8::Persistent<v8::Object> persistent_object = | |
1007 v8::Persistent<v8::Object>::Cast(object); | |
1008 | 1007 |
1009 AliveV8PermissionRequestItem* item_ptr = | 1008 AliveV8PermissionRequestItem* item_ptr = |
1010 static_cast<AliveV8PermissionRequestItem*>(param); | 1009 static_cast<AliveV8PermissionRequestItem*>(param); |
1011 int request_id = item_ptr->first; | 1010 int request_id = item_ptr->first; |
1012 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; | 1011 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; |
1013 delete item_ptr; | 1012 delete item_ptr; |
1014 | 1013 |
1015 persistent_object.Dispose(isolate); | 1014 object->Dispose(); |
1016 persistent_object.Clear(); | |
1017 | 1015 |
1018 if (plugin) { | 1016 if (plugin) { |
1019 // Asynchronously remove item from |alive_v8_permission_request_objects_|. | 1017 // Asynchronously remove item from |alive_v8_permission_request_objects_|. |
1020 // Note that we are using weak pointer for the following PostTask, so we | 1018 // Note that we are using weak pointer for the following PostTask, so we |
1021 // don't need to worry about BrowserPlugin going away. | 1019 // don't need to worry about BrowserPlugin going away. |
1022 base::MessageLoop::current()->PostTask( | 1020 base::MessageLoop::current()->PostTask( |
1023 FROM_HERE, | 1021 FROM_HERE, |
1024 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, | 1022 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, |
1025 plugin, | 1023 plugin, |
1026 request_id)); | 1024 request_id)); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 const WebKit::WebMouseEvent& event) { | 1572 const WebKit::WebMouseEvent& event) { |
1575 browser_plugin_manager()->Send( | 1573 browser_plugin_manager()->Send( |
1576 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1574 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1577 instance_id_, | 1575 instance_id_, |
1578 plugin_rect_, | 1576 plugin_rect_, |
1579 &event)); | 1577 &event)); |
1580 return true; | 1578 return true; |
1581 } | 1579 } |
1582 | 1580 |
1583 } // namespace content | 1581 } // namespace content |
OLD | NEW |