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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 12398007: Replaced deprecated v8 API calls by their non-deprecated counterparts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | « content/renderer/browser_plugin/browser_plugin.h ('k') | net/proxy/proxy_resolver_v8.h » ('j') | 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 "content/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 848
849 void BrowserPlugin::PersistRequestObject( 849 void BrowserPlugin::PersistRequestObject(
850 const NPVariant* request, const std::string& type, int id) { 850 const NPVariant* request, const std::string& type, int id) {
851 CHECK(alive_v8_permission_request_objects_.find(id) == 851 CHECK(alive_v8_permission_request_objects_.find(id) ==
852 alive_v8_permission_request_objects_.end()); 852 alive_v8_permission_request_objects_.end());
853 if (pending_permission_requests_.find(id) == 853 if (pending_permission_requests_.find(id) ==
854 pending_permission_requests_.end()) { 854 pending_permission_requests_.end()) {
855 return; 855 return;
856 } 856 }
857 857
858 v8::Isolate* isolate = v8::Isolate::GetCurrent();
858 v8::Persistent<v8::Value> weak_request = 859 v8::Persistent<v8::Value> weak_request =
859 v8::Persistent<v8::Value>::New(WebKit::WebBindings::toV8Value(request)); 860 v8::Persistent<v8::Value>::New(isolate,
861 WebKit::WebBindings::toV8Value(request));
860 862
861 AliveV8PermissionRequestItem* new_item = 863 AliveV8PermissionRequestItem* new_item =
862 new std::pair<int, base::WeakPtr<BrowserPlugin> >( 864 new std::pair<int, base::WeakPtr<BrowserPlugin> >(
863 id, weak_ptr_factory_.GetWeakPtr()); 865 id, weak_ptr_factory_.GetWeakPtr());
864 866
865 std::pair<std::map<int, AliveV8PermissionRequestItem*>::iterator, bool> 867 std::pair<std::map<int, AliveV8PermissionRequestItem*>::iterator, bool>
866 result = alive_v8_permission_request_objects_.insert( 868 result = alive_v8_permission_request_objects_.insert(
867 std::make_pair(id, new_item)); 869 std::make_pair(id, new_item));
868 CHECK(result.second); // Inserted in the map. 870 CHECK(result.second); // Inserted in the map.
869 AliveV8PermissionRequestItem* request_item = result.first->second; 871 AliveV8PermissionRequestItem* request_item = result.first->second;
870 weak_request.MakeWeak(request_item, WeakCallbackForPersistObject); 872 weak_request.MakeWeak(isolate, request_item, WeakCallbackForPersistObject);
871 } 873 }
872 874
873 // static 875 // static
874 void BrowserPlugin::WeakCallbackForPersistObject( 876 void BrowserPlugin::WeakCallbackForPersistObject(
875 v8::Persistent<v8::Value> object, void* param) { 877 v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* param) {
876 v8::Persistent<v8::Object> persistent_object = 878 v8::Persistent<v8::Object> persistent_object =
877 v8::Persistent<v8::Object>::Cast(object); 879 v8::Persistent<v8::Object>::Cast(object);
878 880
879 AliveV8PermissionRequestItem* item_ptr = 881 AliveV8PermissionRequestItem* item_ptr =
880 static_cast<AliveV8PermissionRequestItem*>(param); 882 static_cast<AliveV8PermissionRequestItem*>(param);
881 int request_id = item_ptr->first; 883 int request_id = item_ptr->first;
882 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second; 884 base::WeakPtr<BrowserPlugin> plugin = item_ptr->second;
883 delete item_ptr; 885 delete item_ptr;
884 886
885 persistent_object.Dispose(); 887 persistent_object.Dispose(isolate);
886 persistent_object.Clear(); 888 persistent_object.Clear();
887 889
888 if (plugin) { 890 if (plugin) {
889 // Asynchronously remove item from |alive_v8_permission_request_objects_|. 891 // Asynchronously remove item from |alive_v8_permission_request_objects_|.
890 // Note that we are using weak pointer for the following PostTask, so we 892 // Note that we are using weak pointer for the following PostTask, so we
891 // don't need to worry about BrowserPlugin going away. 893 // don't need to worry about BrowserPlugin going away.
892 MessageLoop::current()->PostTask( 894 MessageLoop::current()->PostTask(
893 FROM_HERE, 895 FROM_HERE,
894 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected, 896 base::Bind(&BrowserPlugin::OnRequestObjectGarbageCollected,
895 plugin, request_id)); 897 plugin, request_id));
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 void* notify_data) { 1330 void* notify_data) {
1329 } 1331 }
1330 1332
1331 void BrowserPlugin::didFailLoadingFrameRequest( 1333 void BrowserPlugin::didFailLoadingFrameRequest(
1332 const WebKit::WebURL& url, 1334 const WebKit::WebURL& url,
1333 void* notify_data, 1335 void* notify_data,
1334 const WebKit::WebURLError& error) { 1336 const WebKit::WebURLError& error) {
1335 } 1337 }
1336 1338
1337 } // namespace content 1339 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | net/proxy/proxy_resolver_v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698