diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 23:17:16 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-20 23:17:16 +0000 |
commit | f3add92d73df86fa62bf727b0016e0c62149b326 (patch) | |
tree | f2d0012dd68061378276814f1c5108e010bda7a5 /android_webview | |
parent | 13c3497e0bf749e2bf9bb4e0112bf7b1bab63933 (diff) | |
download | chromium_src-f3add92d73df86fa62bf727b0016e0c62149b326.zip chromium_src-f3add92d73df86fa62bf727b0016e0c62149b326.tar.gz chromium_src-f3add92d73df86fa62bf727b0016e0c62149b326.tar.bz2 |
A bunch of work to transition from render_view_id to render_frame_id.
-remove ResourceRequestInfo::GetRenderViewForRequest
-reduce usage of GetAssociatedRenderView and add GetAssociatedRenderFrame which will replace it
-move the cookie jar from RenderView to RenderFrame
-switch most of the usages of RenderView to RenderFrame in WebPluginImpl
BUG=304341
R=boliu@chromium.org, nasko@chromium.org
Review URL: https://codereview.chromium.org/114573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
12 files changed, 135 insertions, 115 deletions
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc index 2e614ee..e19d63d 100644 --- a/android_webview/browser/aw_content_browser_client.cc +++ b/android_webview/browser/aw_content_browser_client.cc @@ -258,13 +258,13 @@ bool AwContentBrowserClient::AllowGetCookie(const GURL& url, const net::CookieList& cookie_list, content::ResourceContext* context, int render_process_id, - int render_view_id) { + int render_frame_id) { return AwCookieAccessPolicy::GetInstance()->AllowGetCookie(url, first_party, cookie_list, context, render_process_id, - render_view_id); + render_frame_id); } bool AwContentBrowserClient::AllowSetCookie(const GURL& url, @@ -272,14 +272,14 @@ bool AwContentBrowserClient::AllowSetCookie(const GURL& url, const std::string& cookie_line, content::ResourceContext* context, int render_process_id, - int render_view_id, + int render_frame_id, net::CookieOptions* options) { return AwCookieAccessPolicy::GetInstance()->AllowSetCookie(url, first_party, cookie_line, context, render_process_id, - render_view_id, + render_frame_id, options); } diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h index 5d5233d..ac15cc7 100644 --- a/android_webview/browser/aw_content_browser_client.h +++ b/android_webview/browser/aw_content_browser_client.h @@ -66,13 +66,13 @@ class AwContentBrowserClient : public content::ContentBrowserClient { const net::CookieList& cookie_list, content::ResourceContext* context, int render_process_id, - int render_view_id) OVERRIDE; + int render_frame_id) OVERRIDE; virtual bool AllowSetCookie(const GURL& url, const GURL& first_party, const std::string& cookie_line, content::ResourceContext* context, int render_process_id, - int render_view_id, + int render_frame_id, net::CookieOptions* options) OVERRIDE; virtual bool AllowWorkerDatabase( const GURL& url, diff --git a/android_webview/browser/aw_contents_io_thread_client.h b/android_webview/browser/aw_contents_io_thread_client.h index aedfba2..11c17f7 100644 --- a/android_webview/browser/aw_contents_io_thread_client.h +++ b/android_webview/browser/aw_contents_io_thread_client.h @@ -56,11 +56,11 @@ class AwContentsIoThreadClient { virtual CacheMode GetCacheMode() const = 0; // This will attempt to fetch the AwContentsIoThreadClient for the given - // |render_process_id|, |render_view_id| pair. + // |render_process_id|, |render_frame_id| pair. // This method can be called from any thread. // An empty scoped_ptr is a valid return value. static scoped_ptr<AwContentsIoThreadClient> FromID(int render_process_id, - int render_view_id); + int render_frame_id); // This method is called on the IO thread only. virtual scoped_ptr<InterceptedRequestData> ShouldInterceptRequest( diff --git a/android_webview/browser/aw_cookie_access_policy.cc b/android_webview/browser/aw_cookie_access_policy.cc index 550ab35..15158b9 100644 --- a/android_webview/browser/aw_cookie_access_policy.cc +++ b/android_webview/browser/aw_cookie_access_policy.cc @@ -54,7 +54,7 @@ bool AwCookieAccessPolicy::AllowGetCookie(const GURL& url, const net::CookieList& cookie_list, content::ResourceContext* context, int render_process_id, - int render_view_id) { + int render_frame_id) { return GetGlobalAllowAccess(); } @@ -63,7 +63,7 @@ bool AwCookieAccessPolicy::AllowSetCookie(const GURL& url, const std::string& cookie_line, content::ResourceContext* context, int render_process_id, - int render_view_id, + int render_frame_id, net::CookieOptions* options) { return GetGlobalAllowAccess(); } diff --git a/android_webview/browser/aw_cookie_access_policy.h b/android_webview/browser/aw_cookie_access_policy.h index b25e4f6..7014521 100644 --- a/android_webview/browser/aw_cookie_access_policy.h +++ b/android_webview/browser/aw_cookie_access_policy.h @@ -48,13 +48,13 @@ class AwCookieAccessPolicy { const net::CookieList& cookie_list, content::ResourceContext* context, int render_process_id, - int render_view_id); + int render_frame_id); bool AllowSetCookie(const GURL& url, const GURL& first_party, const std::string& cookie_line, content::ResourceContext* context, int render_process_id, - int render_view_id, + int render_frame_id, net::CookieOptions* options); private: diff --git a/android_webview/browser/aw_login_delegate.cc b/android_webview/browser/aw_login_delegate.cc index 84ef2cb2..5656b91 100644 --- a/android_webview/browser/aw_login_delegate.cc +++ b/android_webview/browser/aw_login_delegate.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/supports_user_data.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/resource_request_info.h" #include "content/public/browser/web_contents.h" @@ -18,7 +18,7 @@ using namespace base::android; using content::BrowserThread; -using content::RenderViewHost; +using content::RenderFrameHost; using content::ResourceDispatcherHost; using content::ResourceRequestInfo; using content::WebContents; @@ -41,9 +41,9 @@ AwLoginDelegate::AwLoginDelegate(net::AuthChallengeInfo* auth_info, : auth_info_(auth_info), request_(request), render_process_id_(0), - render_view_id_(0) { - ResourceRequestInfo::GetRenderViewForRequest( - request, &render_process_id_, &render_view_id_); + render_frame_id_(0) { + ResourceRequestInfo::GetRenderFrameForRequest( + request, &render_process_id_, &render_frame_id_); UrlRequestAuthAttemptsData* count = static_cast<UrlRequestAuthAttemptsData*>( @@ -87,15 +87,15 @@ void AwLoginDelegate::HandleHttpAuthRequestOnUIThread( aw_http_auth_handler_.reset(AwHttpAuthHandlerBase::Create( this, auth_info_.get(), first_auth_attempt)); - RenderViewHost* render_view_host = RenderViewHost::FromID( - render_process_id_, render_view_id_); - if (!render_view_host) { + RenderFrameHost* render_frame_host = RenderFrameHost::FromID( + render_process_id_, render_frame_id_); + if (!render_frame_host) { Cancel(); return; } - WebContents* web_contents = WebContents::FromRenderViewHost( - render_view_host); + WebContents* web_contents = WebContents::FromRenderFrameHost( + render_frame_host); if (!aw_http_auth_handler_->HandleOnUIThread(web_contents)) { Cancel(); return; diff --git a/android_webview/browser/aw_login_delegate.h b/android_webview/browser/aw_login_delegate.h index f0f8769..7d13400 100644 --- a/android_webview/browser/aw_login_delegate.h +++ b/android_webview/browser/aw_login_delegate.h @@ -43,7 +43,7 @@ class AwLoginDelegate : scoped_refptr<net::AuthChallengeInfo> auth_info_; net::URLRequest* request_; int render_process_id_; - int render_view_id_; + int render_frame_id_; }; } // namespace android_webview diff --git a/android_webview/browser/aw_request_interceptor.cc b/android_webview/browser/aw_request_interceptor.cc index 72673d2..e61d04b 100644 --- a/android_webview/browser/aw_request_interceptor.cc +++ b/android_webview/browser/aw_request_interceptor.cc @@ -39,13 +39,13 @@ AwRequestInterceptor::QueryForInterceptedRequestData( const GURL& location, net::URLRequest* request) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - int render_process_id, render_view_id; - if (!ResourceRequestInfo::GetRenderViewForRequest( - request, &render_process_id, &render_view_id)) + int render_process_id, render_frame_id; + if (!ResourceRequestInfo::GetRenderFrameForRequest( + request, &render_process_id, &render_frame_id)) return scoped_ptr<InterceptedRequestData>(); scoped_ptr<AwContentsIoThreadClient> io_thread_client = - AwContentsIoThreadClient::FromID(render_process_id, render_view_id); + AwContentsIoThreadClient::FromID(render_process_id, render_frame_id); if (!io_thread_client.get()) return scoped_ptr<InterceptedRequestData>(); diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc index 5042dcd..195d79a 100644 --- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc +++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc @@ -53,13 +53,13 @@ namespace android_webview { // Calls through the IoThreadClient to check the embedders settings to determine // if the request should be cancelled. There may not always be an IoThreadClient -// available for the |child_id|, |route_id| pair (in the case of newly created -// pop up windows, for example) and in that case the request and the client -// callbacks will be deferred the request until a client is ready. +// available for the |render_process_id|, |render_frame_id| pair (in the case of +// newly created pop up windows, for example) and in that case the request and +// the client callbacks will be deferred the request until a client is ready. class IoThreadClientThrottle : public content::ResourceThrottle { public: - IoThreadClientThrottle(int child_id, - int route_id, + IoThreadClientThrottle(int render_process_id, + int render_frame_id, net::URLRequest* request); virtual ~IoThreadClientThrottle(); @@ -68,23 +68,24 @@ class IoThreadClientThrottle : public content::ResourceThrottle { virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; virtual const char* GetNameForLogging() const OVERRIDE; - void OnIoThreadClientReady(int new_child_id, int new_route_id); + void OnIoThreadClientReady(int new_render_process_id, + int new_render_frame_id); bool MaybeBlockRequest(); bool ShouldBlockRequest(); - int get_child_id() const { return child_id_; } - int get_route_id() const { return route_id_; } + int render_process_id() const { return render_process_id_; } + int render_frame_id() const { return render_frame_id_; } -private: - int child_id_; - int route_id_; + private: + int render_process_id_; + int render_frame_id_; net::URLRequest* request_; }; -IoThreadClientThrottle::IoThreadClientThrottle(int child_id, - int route_id, +IoThreadClientThrottle::IoThreadClientThrottle(int render_process_id, + int render_frame_id, net::URLRequest* request) - : child_id_(child_id), - route_id_(route_id), + : render_process_id_(render_process_id), + render_frame_id_(render_frame_id), request_(request) { } IoThreadClientThrottle::~IoThreadClientThrottle() { @@ -100,22 +101,22 @@ const char* IoThreadClientThrottle::GetNameForLogging() const { void IoThreadClientThrottle::WillStartRequest(bool* defer) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); // TODO(sgurun): This block can be removed when crbug.com/277937 is fixed. - if (route_id_ < 1) { + if (render_frame_id_ < 1) { // OPTIONS is used for preflighted requests which are generated internally. DCHECK_EQ("OPTIONS", request_->method()); return; } - DCHECK(child_id_); + DCHECK(render_process_id_); *defer = false; // Defer all requests of a pop up that is still not associated with Java // client so that the client will get a chance to override requests. scoped_ptr<AwContentsIoThreadClient> io_client = - AwContentsIoThreadClient::FromID(child_id_, route_id_); + AwContentsIoThreadClient::FromID(render_process_id_, render_frame_id_); if (io_client && io_client->PendingAssociation()) { *defer = true; AwResourceDispatcherHostDelegate::AddPendingThrottle( - child_id_, route_id_, this); + render_process_id_, render_frame_id_, this); } else { MaybeBlockRequest(); } @@ -126,8 +127,8 @@ void IoThreadClientThrottle::WillRedirectRequest(const GURL& new_url, WillStartRequest(defer); } -void IoThreadClientThrottle::OnIoThreadClientReady(int new_child_id, - int new_route_id) { +void IoThreadClientThrottle::OnIoThreadClientReady(int new_render_process_id, + int new_render_frame_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!MaybeBlockRequest()) { @@ -145,7 +146,7 @@ bool IoThreadClientThrottle::MaybeBlockRequest() { bool IoThreadClientThrottle::ShouldBlockRequest() { scoped_ptr<AwContentsIoThreadClient> io_client = - AwContentsIoThreadClient::FromID(child_id_, route_id_); + AwContentsIoThreadClient::FromID(render_process_id_, render_frame_id_); if (!io_client) return false; @@ -215,13 +216,16 @@ void AwResourceDispatcherHostDelegate::RequestBeginning( AddExtraHeadersIfNeeded(request, resource_context); + const content::ResourceRequestInfo* request_info = + content::ResourceRequestInfo::ForRequest(request); + // We always push the throttles here. Checking the existence of io_client // is racy when a popup window is created. That is because RequestBeginning // is called whether or not requests are blocked via BlockRequestForRoute() // however io_client may or may not be ready at the time depending on whether // webcontents is created. throttles->push_back(new IoThreadClientThrottle( - child_id, route_id, request)); + child_id, request_info->GetRenderFrameID(), request)); // We allow intercepting only navigations within main frames. This // is used to post onPageStarted. We handle shouldOverrideUrlLoading @@ -268,8 +272,12 @@ void AwResourceDispatcherHostDelegate::DownloadStarting( request->Cancel(); + const content::ResourceRequestInfo* request_info = + content::ResourceRequestInfo::ForRequest(request); + scoped_ptr<AwContentsIoThreadClient> io_client = - AwContentsIoThreadClient::FromID(child_id, route_id); + AwContentsIoThreadClient::FromID( + child_id, request_info->GetRenderFrameID()); // POST request cannot be repeated in general, so prevent client from // retrying the same request, even if it is with a GET. @@ -337,7 +345,7 @@ void AwResourceDispatcherHostDelegate::OnResponseStarted( request, auto_login_parser::ALLOW_ANY_REALM, &header_data)) { scoped_ptr<AwContentsIoThreadClient> io_client = AwContentsIoThreadClient::FromID(request_info->GetChildID(), - request_info->GetRouteID()); + request_info->GetRenderFrameID()); if (io_client) { io_client->NewLoginRequest( header_data.realm, header_data.account, header_data.args); @@ -350,7 +358,8 @@ void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread( IoThreadClientThrottle* throttle) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); PendingThrottleMap::iterator it = pending_throttles_.find( - ChildRouteIDPair(throttle->get_child_id(), throttle->get_route_id())); + FrameRouteIDPair(throttle->render_process_id(), + throttle->render_frame_id())); if (it != pending_throttles_.end()) { pending_throttles_.erase(it); } @@ -358,49 +367,50 @@ void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread( // static void AwResourceDispatcherHostDelegate::OnIoThreadClientReady( - int new_child_id, - int new_route_id) { + int new_render_process_id, + int new_render_frame_id) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( &AwResourceDispatcherHostDelegate::OnIoThreadClientReadyInternal, base::Unretained( g_webview_resource_dispatcher_host_delegate.Pointer()), - new_child_id, new_route_id)); + new_render_process_id, new_render_frame_id)); } // static void AwResourceDispatcherHostDelegate::AddPendingThrottle( - int child_id, - int route_id, + int render_process_id, + int render_frame_id, IoThreadClientThrottle* pending_throttle) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( &AwResourceDispatcherHostDelegate::AddPendingThrottleOnIoThread, base::Unretained( g_webview_resource_dispatcher_host_delegate.Pointer()), - child_id, route_id, pending_throttle)); + render_process_id, render_frame_id, pending_throttle)); } void AwResourceDispatcherHostDelegate::AddPendingThrottleOnIoThread( - int child_id, - int route_id, + int render_process_id, + int render_frame_id_id, IoThreadClientThrottle* pending_throttle) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); pending_throttles_.insert( - std::pair<ChildRouteIDPair, IoThreadClientThrottle*>( - ChildRouteIDPair(child_id, route_id), pending_throttle)); + std::pair<FrameRouteIDPair, IoThreadClientThrottle*>( + FrameRouteIDPair(render_process_id, render_frame_id_id), + pending_throttle)); } void AwResourceDispatcherHostDelegate::OnIoThreadClientReadyInternal( - int new_child_id, - int new_route_id) { + int new_render_process_id, + int new_render_frame_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); PendingThrottleMap::iterator it = pending_throttles_.find( - ChildRouteIDPair(new_child_id, new_route_id)); + FrameRouteIDPair(new_render_process_id, new_render_frame_id)); if (it != pending_throttles_.end()) { IoThreadClientThrottle* throttle = it->second; - throttle->OnIoThreadClientReady(new_child_id, new_route_id); + throttle->OnIoThreadClientReady(new_render_process_id, new_render_frame_id); pending_throttles_.erase(it); } } diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h index 1ae3333..d669ff7 100644 --- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h +++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h @@ -72,9 +72,10 @@ class AwResourceDispatcherHostDelegate void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle); - static void OnIoThreadClientReady(int new_child_id, int new_route_id); - static void AddPendingThrottle(int child_id, - int route_id, + static void OnIoThreadClientReady(int new_render_process_id, + int new_render_frame_id); + static void AddPendingThrottle(int render_process_id, + int render_frame_id, IoThreadClientThrottle* pending_throttle); private: @@ -84,15 +85,17 @@ class AwResourceDispatcherHostDelegate virtual ~AwResourceDispatcherHostDelegate(); // These methods must be called on IO thread. - void OnIoThreadClientReadyInternal(int child_id, int route_id); - void AddPendingThrottleOnIoThread(int child_id, - int route_id, + void OnIoThreadClientReadyInternal(int new_render_process_id, + int new_render_frame_id); + void AddPendingThrottleOnIoThread(int render_process_id, + int render_frame_id, IoThreadClientThrottle* pending_throttle); void AddExtraHeadersIfNeeded(net::URLRequest* request, content::ResourceContext* resource_context); - typedef std::pair<int, int> ChildRouteIDPair; - typedef std::map<ChildRouteIDPair, IoThreadClientThrottle*> + // Pair of render_process_id and render_frame_id. + typedef std::pair<int, int> FrameRouteIDPair; + typedef std::map<FrameRouteIDPair, IoThreadClientThrottle*> PendingThrottleMap; // Only accessed on the IO thread. diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 3df421f..9e10dd1 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -45,6 +45,7 @@ #include "content/public/browser/cert_store.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -159,6 +160,13 @@ GetRendererPreferencesSubpixelRenderingEnum( } } +void OnIoThreadClientReady(content::RenderFrameHost* rfh) { + int render_process_id = rfh->GetProcess()->GetID(); + int render_frame_id = rfh->GetRoutingID(); + AwResourceDispatcherHostDelegate::OnIoThreadClientReady( + render_process_id, render_frame_id); +} + } // namespace // static @@ -229,9 +237,7 @@ void AwContents::SetJavaPeers(JNIEnv* env, env, intercept_navigation_delegate))); // Finally, having setup the associations, release any deferred requests - int child_id = web_contents_->GetRenderProcessHost()->GetID(); - int route_id = web_contents_->GetRoutingID(); - AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id); + web_contents_->ForEachFrame(base::Bind(&OnIoThreadClientReady)); } void AwContents::SetSaveFormData(bool enabled) { diff --git a/android_webview/native/aw_contents_io_thread_client_impl.cc b/android_webview/native/aw_contents_io_thread_client_impl.cc index 6e24d9a..ccdbbff 100644 --- a/android_webview/native/aw_contents_io_thread_client_impl.cc +++ b/android_webview/native/aw_contents_io_thread_client_impl.cc @@ -15,6 +15,7 @@ #include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_request_info.h" @@ -30,7 +31,7 @@ using base::android::JavaRef; using base::android::ScopedJavaLocalRef; using base::LazyInstance; using content::BrowserThread; -using content::RenderViewHost; +using content::RenderFrameHost; using content::WebContents; using std::map; using std::pair; @@ -49,56 +50,56 @@ struct IoThreadClientData { IoThreadClientData::IoThreadClientData() : pending_association(false) {} typedef map<pair<int, int>, IoThreadClientData> - RenderViewHostToIoThreadClientType; + RenderFrameHostToIoThreadClientType; -static pair<int, int> GetRenderViewHostIdPair(RenderViewHost* rvh) { - return pair<int, int>(rvh->GetProcess()->GetID(), rvh->GetRoutingID()); +static pair<int, int> GetRenderFrameHostIdPair(RenderFrameHost* rfh) { + return pair<int, int>(rfh->GetProcess()->GetID(), rfh->GetRoutingID()); } -// RvhToIoThreadClientMap ----------------------------------------------------- -class RvhToIoThreadClientMap { +// RfhToIoThreadClientMap ----------------------------------------------------- +class RfhToIoThreadClientMap { public: - static RvhToIoThreadClientMap* GetInstance(); - void Set(pair<int, int> rvh_id, const IoThreadClientData& client); - bool Get(pair<int, int> rvh_id, IoThreadClientData* client); - void Erase(pair<int, int> rvh_id); + static RfhToIoThreadClientMap* GetInstance(); + void Set(pair<int, int> rfh_id, const IoThreadClientData& client); + bool Get(pair<int, int> rfh_id, IoThreadClientData* client); + void Erase(pair<int, int> rfh_id); private: - static LazyInstance<RvhToIoThreadClientMap> g_instance_; + static LazyInstance<RfhToIoThreadClientMap> g_instance_; base::Lock map_lock_; - RenderViewHostToIoThreadClientType rvh_to_io_thread_client_; + RenderFrameHostToIoThreadClientType rfh_to_io_thread_client_; }; // static -LazyInstance<RvhToIoThreadClientMap> RvhToIoThreadClientMap::g_instance_ = +LazyInstance<RfhToIoThreadClientMap> RfhToIoThreadClientMap::g_instance_ = LAZY_INSTANCE_INITIALIZER; // static -RvhToIoThreadClientMap* RvhToIoThreadClientMap::GetInstance() { +RfhToIoThreadClientMap* RfhToIoThreadClientMap::GetInstance() { return g_instance_.Pointer(); } -void RvhToIoThreadClientMap::Set(pair<int, int> rvh_id, +void RfhToIoThreadClientMap::Set(pair<int, int> rfh_id, const IoThreadClientData& client) { base::AutoLock lock(map_lock_); - rvh_to_io_thread_client_[rvh_id] = client; + rfh_to_io_thread_client_[rfh_id] = client; } -bool RvhToIoThreadClientMap::Get( - pair<int, int> rvh_id, IoThreadClientData* client) { +bool RfhToIoThreadClientMap::Get( + pair<int, int> rfh_id, IoThreadClientData* client) { base::AutoLock lock(map_lock_); - RenderViewHostToIoThreadClientType::iterator iterator = - rvh_to_io_thread_client_.find(rvh_id); - if (iterator == rvh_to_io_thread_client_.end()) + RenderFrameHostToIoThreadClientType::iterator iterator = + rfh_to_io_thread_client_.find(rfh_id); + if (iterator == rfh_to_io_thread_client_.end()) return false; *client = iterator->second; return true; } -void RvhToIoThreadClientMap::Erase(pair<int, int> rvh_id) { +void RfhToIoThreadClientMap::Erase(pair<int, int> rfh_id) { base::AutoLock lock(map_lock_); - rvh_to_io_thread_client_.erase(rvh_id); + rfh_to_io_thread_client_.erase(rfh_id); } // ClientMapEntryUpdater ------------------------------------------------------ @@ -108,8 +109,8 @@ class ClientMapEntryUpdater : public content::WebContentsObserver { ClientMapEntryUpdater(JNIEnv* env, WebContents* web_contents, jobject jdelegate); - virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; - virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; + virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE; + virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; private: @@ -124,20 +125,20 @@ ClientMapEntryUpdater::ClientMapEntryUpdater(JNIEnv* env, DCHECK(web_contents); DCHECK(jdelegate); - if (web_contents->GetRenderViewHost()) - RenderViewCreated(web_contents->GetRenderViewHost()); + if (web_contents->GetMainFrame()) + RenderFrameCreated(web_contents->GetMainFrame()); } -void ClientMapEntryUpdater::RenderViewCreated(RenderViewHost* rvh) { +void ClientMapEntryUpdater::RenderFrameCreated(RenderFrameHost* rfh) { IoThreadClientData client_data; client_data.io_thread_client = jdelegate_; client_data.pending_association = false; - RvhToIoThreadClientMap::GetInstance()->Set( - GetRenderViewHostIdPair(rvh), client_data); + RfhToIoThreadClientMap::GetInstance()->Set( + GetRenderFrameHostIdPair(rfh), client_data); } -void ClientMapEntryUpdater::RenderViewDeleted(RenderViewHost* rvh) { - RvhToIoThreadClientMap::GetInstance()->Erase(GetRenderViewHostIdPair(rvh)); +void ClientMapEntryUpdater::RenderFrameDeleted(RenderFrameHost* rfh) { + RfhToIoThreadClientMap::GetInstance()->Erase(GetRenderFrameHostIdPair(rfh)); } void ClientMapEntryUpdater::WebContentsDestroyed(WebContents* web_contents) { @@ -150,10 +151,10 @@ void ClientMapEntryUpdater::WebContentsDestroyed(WebContents* web_contents) { // static scoped_ptr<AwContentsIoThreadClient> -AwContentsIoThreadClient::FromID(int render_process_id, int render_view_id) { - pair<int, int> rvh_id(render_process_id, render_view_id); +AwContentsIoThreadClient::FromID(int render_process_id, int render_frame_id) { + pair<int, int> rfh_id(render_process_id, render_frame_id); IoThreadClientData client_data; - if (!RvhToIoThreadClientMap::GetInstance()->Get(rvh_id, &client_data)) + if (!RfhToIoThreadClientMap::GetInstance()->Get(rfh_id, &client_data)) return scoped_ptr<AwContentsIoThreadClient>(); JNIEnv* env = AttachCurrentThread(); @@ -169,8 +170,8 @@ void AwContentsIoThreadClientImpl::RegisterPendingContents( WebContents* web_contents) { IoThreadClientData client_data; client_data.pending_association = true; - RvhToIoThreadClientMap::GetInstance()->Set( - GetRenderViewHostIdPair(web_contents->GetRenderViewHost()), client_data); + RfhToIoThreadClientMap::GetInstance()->Set( + GetRenderFrameHostIdPair(web_contents->GetMainFrame()), client_data); } // static |