diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 03:26:31 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 03:26:31 +0000 |
commit | 09b361bb179774528ec027d879ead3f8f7b159b1 (patch) | |
tree | c3226f064c71cc2680c178751e700d9922764627 | |
parent | 704ccaa1ae493546fd1f1bcb3f8be090e4826038 (diff) | |
download | chromium_src-09b361bb179774528ec027d879ead3f8f7b159b1.zip chromium_src-09b361bb179774528ec027d879ead3f8f7b159b1.tar.gz chromium_src-09b361bb179774528ec027d879ead3f8f7b159b1.tar.bz2 |
Move more code into the content namespace.
R=jam@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11190055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162908 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 235 insertions, 228 deletions
diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc index b0560cb..80d69fe7 100644 --- a/content/browser/renderer_host/clipboard_message_filter.cc +++ b/content/browser/renderer_host/clipboard_message_filter.cc @@ -20,7 +20,7 @@ #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/size.h" -using content::BrowserThread; +namespace content { #if defined(OS_WIN) @@ -247,3 +247,5 @@ ui::Clipboard* ClipboardMessageFilter::GetClipboard() { static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); return clipboard; } + +} // namespace content diff --git a/content/browser/renderer_host/clipboard_message_filter.h b/content/browser/renderer_host/clipboard_message_filter.h index e05540a..d275fc7 100644 --- a/content/browser/renderer_host/clipboard_message_filter.h +++ b/content/browser/renderer_host/clipboard_message_filter.h @@ -14,13 +14,15 @@ class GURL; -class ClipboardMessageFilter : public content::BrowserMessageFilter { +namespace content { + +class ClipboardMessageFilter : public BrowserMessageFilter { public: ClipboardMessageFilter(); virtual void OverrideThreadForMessage( const IPC::Message& message, - content::BrowserThread::ID* thread) OVERRIDE; + BrowserThread::ID* thread) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; private: @@ -62,4 +64,6 @@ class ClipboardMessageFilter : public content::BrowserMessageFilter { DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); }; +} // namespace content + #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/clipboard_message_filter_mac.mm b/content/browser/renderer_host/clipboard_message_filter_mac.mm index 5e26243..4105458 100644 --- a/content/browser/renderer_host/clipboard_message_filter_mac.mm +++ b/content/browser/renderer_host/clipboard_message_filter_mac.mm @@ -13,8 +13,7 @@ #include "content/public/browser/browser_thread.h" #import "ui/base/cocoa/find_pasteboard.h" -using content::BrowserThread; - +namespace content { namespace { // The number of utf16 code units that will be written to the find pasteboard, @@ -52,3 +51,5 @@ void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) { } } } + +} // namespace content diff --git a/content/browser/renderer_host/database_message_filter.cc b/content/browser/renderer_host/database_message_filter.cc index 1cebcb3..f0ff6ca 100644 --- a/content/browser/renderer_host/database_message_filter.cc +++ b/content/browser/renderer_host/database_message_filter.cc @@ -25,9 +25,6 @@ #include "base/file_descriptor_posix.h" #endif -using content::BrowserMessageFilter; -using content::BrowserThread; -using content::UserMetricsAction; using quota::QuotaManager; using quota::QuotaManagerProxy; using quota::QuotaStatusCode; @@ -36,6 +33,7 @@ using webkit_database::DatabaseTracker; using webkit_database::DatabaseUtil; using webkit_database::VfsBackend; +namespace content { namespace { const int kNumDeleteRetries = 2; @@ -300,7 +298,7 @@ void DatabaseMessageFilter::OnDatabaseModified( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); if (!database_connections_.IsDatabaseOpened( origin_identifier, database_name)) { - content::RecordAction(UserMetricsAction("BadMessageTerminate_DBMF")); + RecordAction(UserMetricsAction("BadMessageTerminate_DBMF")); BadMessageReceived(); return; } @@ -313,7 +311,7 @@ void DatabaseMessageFilter::OnDatabaseClosed(const string16& origin_identifier, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); if (!database_connections_.IsDatabaseOpened( origin_identifier, database_name)) { - content::RecordAction(UserMetricsAction("BadMessageTerminate_DBMF")); + RecordAction(UserMetricsAction("BadMessageTerminate_DBMF")); BadMessageReceived(); return; } @@ -347,3 +345,5 @@ void DatabaseMessageFilter::OnDatabaseScheduledForDeletion( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); Send(new DatabaseMsg_CloseImmediately(origin_identifier, database_name)); } + +} // namespace content diff --git a/content/browser/renderer_host/database_message_filter.h b/content/browser/renderer_host/database_message_filter.h index 45fa63c..26d9be3 100644 --- a/content/browser/renderer_host/database_message_filter.h +++ b/content/browser/renderer_host/database_message_filter.h @@ -12,17 +12,19 @@ #include "webkit/database/database_tracker.h" #include "webkit/quota/quota_types.h" +namespace content { + class DatabaseMessageFilter - : public content::BrowserMessageFilter, + : public BrowserMessageFilter, public webkit_database::DatabaseTracker::Observer { public: explicit DatabaseMessageFilter(webkit_database::DatabaseTracker* db_tracker); - // content::BrowserMessageFilter implementation. + // BrowserMessageFilter implementation. virtual void OnChannelClosing() OVERRIDE; virtual void OverrideThreadForMessage( const IPC::Message& message, - content::BrowserThread::ID* thread) OVERRIDE; + BrowserThread::ID* thread) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; @@ -95,4 +97,6 @@ class DatabaseMessageFilter webkit_database::DatabaseConnections database_connections_; }; +} // namespace content + #endif // CONTENT_BROWSER_RENDERER_HOST_DATABASE_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/dip_util.cc b/content/browser/renderer_host/dip_util.cc index 741ce3c..0455020 100644 --- a/content/browser/renderer_host/dip_util.cc +++ b/content/browser/renderer_host/dip_util.cc @@ -13,16 +13,15 @@ #include "ui/gfx/size.h" #include "ui/gfx/size_conversions.h" +namespace content { namespace { -float GetScaleForView(const content::RenderWidgetHostView* view) { - return ui::GetScaleFactorScale(content::GetScaleFactorForView(view)); +float GetScaleForView(const RenderWidgetHostView* view) { + return ui::GetScaleFactorScale(GetScaleFactorForView(view)); } } // namespace -namespace content { - ui::ScaleFactor GetScaleFactorForView(const RenderWidgetHostView* view) { return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL); } diff --git a/content/browser/renderer_host/file_utilities_message_filter.cc b/content/browser/renderer_host/file_utilities_message_filter.cc index 287e18b..6ecf628 100644 --- a/content/browser/renderer_host/file_utilities_message_filter.cc +++ b/content/browser/renderer_host/file_utilities_message_filter.cc @@ -8,7 +8,7 @@ #include "content/browser/child_process_security_policy_impl.h" #include "content/common/file_utilities_messages.h" -using content::BrowserThread; +namespace content { FileUtilitiesMessageFilter::FileUtilitiesMessageFilter(int process_id) : process_id_(process_id) { @@ -89,3 +89,5 @@ void FileUtilitiesMessageFilter::OnOpenFile( *result = base::FileDescriptor(file_handle, true); #endif } + +} // namespace content diff --git a/content/browser/renderer_host/file_utilities_message_filter.h b/content/browser/renderer_host/file_utilities_message_filter.h index 7498aaa..d698885 100644 --- a/content/browser/renderer_host/file_utilities_message_filter.h +++ b/content/browser/renderer_host/file_utilities_message_filter.h @@ -18,14 +18,16 @@ namespace IPC { class Message; } -class FileUtilitiesMessageFilter : public content::BrowserMessageFilter { +namespace content { + +class FileUtilitiesMessageFilter : public BrowserMessageFilter { public: explicit FileUtilitiesMessageFilter(int process_id); - // content::BrowserMessageFilter implementation. + // BrowserMessageFilter implementation. virtual void OverrideThreadForMessage( const IPC::Message& message, - content::BrowserThread::ID* thread) OVERRIDE; + BrowserThread::ID* thread) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; private: @@ -47,4 +49,6 @@ class FileUtilitiesMessageFilter : public content::BrowserMessageFilter { DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilitiesMessageFilter); }; +} // namespace content + #endif // CONTENT_BROWSER_RENDERER_HOST_FILE_UTILITIES_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/gamepad_browser_message_filter.cc b/content/browser/renderer_host/gamepad_browser_message_filter.cc index c06eec2..71c2aab 100644 --- a/content/browser/renderer_host/gamepad_browser_message_filter.cc +++ b/content/browser/renderer_host/gamepad_browser_message_filter.cc @@ -7,8 +7,6 @@ #include "content/browser/gamepad/gamepad_service.h" #include "content/common/gamepad_messages.h" -using content::BrowserMessageFilter; - namespace content { GamepadBrowserMessageFilter::GamepadBrowserMessageFilter() diff --git a/content/browser/renderer_host/gamepad_browser_message_filter.h b/content/browser/renderer_host/gamepad_browser_message_filter.h index 8f09365..51dfb9d 100644 --- a/content/browser/renderer_host/gamepad_browser_message_filter.h +++ b/content/browser/renderer_host/gamepad_browser_message_filter.h @@ -14,11 +14,11 @@ namespace content { class GamepadService; class RenderProcessHost; -class GamepadBrowserMessageFilter : public content::BrowserMessageFilter { +class GamepadBrowserMessageFilter : public BrowserMessageFilter { public: GamepadBrowserMessageFilter(); - // content::BrowserMessageFilter implementation. + // BrowserMessageFilter implementation. virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; diff --git a/content/browser/renderer_host/quota_dispatcher_host.cc b/content/browser/renderer_host/quota_dispatcher_host.cc index 0d8876d..65ad839 100644 --- a/content/browser/renderer_host/quota_dispatcher_host.cc +++ b/content/browser/renderer_host/quota_dispatcher_host.cc @@ -12,12 +12,13 @@ #include "net/base/net_util.h" #include "webkit/quota/quota_manager.h" -using content::QuotaPermissionContext; using quota::QuotaClient; using quota::QuotaManager; using quota::QuotaStatusCode; using quota::StorageType; +namespace content { + // Created one per request to carry the request's request_id around. // Dispatches requests from renderer/worker to the QuotaManager and // sends back the response to the renderer/worker. @@ -248,3 +249,5 @@ void QuotaDispatcherHost::OnRequestStorageQuota( this, request_id, origin, type, requested_size, render_view_id); dispatcher->Start(); } + +} // namespace content diff --git a/content/browser/renderer_host/quota_dispatcher_host.h b/content/browser/renderer_host/quota_dispatcher_host.h index c5c6347..c4c098f 100644 --- a/content/browser/renderer_host/quota_dispatcher_host.h +++ b/content/browser/renderer_host/quota_dispatcher_host.h @@ -12,10 +12,6 @@ class GURL; -namespace content { -class QuotaPermissionContext; -} - namespace IPC { class Message; } @@ -24,13 +20,16 @@ namespace quota { class QuotaManager; } -class QuotaDispatcherHost : public content::BrowserMessageFilter { +namespace content { +class QuotaPermissionContext; + +class QuotaDispatcherHost : public BrowserMessageFilter { public: QuotaDispatcherHost(int process_id, quota::QuotaManager* quota_manager, - content::QuotaPermissionContext* permission_context); + QuotaPermissionContext* permission_context); - // content::BrowserMessageFilter: + // BrowserMessageFilter: virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; @@ -57,11 +56,13 @@ class QuotaDispatcherHost : public content::BrowserMessageFilter { int process_id_; quota::QuotaManager* quota_manager_; - scoped_refptr<content::QuotaPermissionContext> permission_context_; + scoped_refptr<QuotaPermissionContext> permission_context_; IDMap<RequestDispatcher, IDMapOwnPointer> outstanding_requests_; DISALLOW_IMPLICIT_CONSTRUCTORS(QuotaDispatcherHost); }; +} // namespace content + #endif // CONTENT_BROWSER_RENDERER_HOST_QUOTA_DISPATCHER_HOST_H_ diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index d5eeb4aa..c3067a2 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -79,8 +79,6 @@ #endif using base::TimeDelta; -using content::NativeWebKeyboardEvent; -using content::RenderViewHostDelegateView; using WebKit::WebConsoleMessage; using WebKit::WebDragOperation; using WebKit::WebDragOperationNone; @@ -89,6 +87,7 @@ using WebKit::WebInputEvent; using WebKit::WebMediaPlayerAction; using WebKit::WebPluginAction; +namespace content { namespace { // Delay to wait on closing the WebContents for a beforeunload/unload handler to @@ -111,8 +110,6 @@ base::i18n::TextDirection WebTextDirectionToChromeTextDirection( } // namespace -namespace content { - /////////////////////////////////////////////////////////////////////////////// // RenderViewHost, public: @@ -185,12 +182,12 @@ RenderViewHostImpl::RenderViewHostImpl( GetProcess()->EnableSendQueue(); - content::GetContentClient()->browser()->RenderViewHostCreated(this); + GetContentClient()->browser()->RenderViewHostCreated(this); - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, - content::Source<RenderViewHost>(this), - content::NotificationService::NoDetails()); + NotificationService::current()->Notify( + NOTIFICATION_RENDER_VIEW_HOST_CREATED, + Source<RenderViewHost>(this), + NotificationService::NoDetails()); #if defined(OS_ANDROID) media_player_manager_ = new MediaPlayerManagerAndroid(this); @@ -199,12 +196,12 @@ RenderViewHostImpl::RenderViewHostImpl( RenderViewHostImpl::~RenderViewHostImpl() { FOR_EACH_OBSERVER( - content::RenderViewHostObserver, observers_, RenderViewHostDestruction()); + RenderViewHostObserver, observers_, RenderViewHostDestruction()); - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, - content::Source<RenderViewHost>(this), - content::NotificationService::NoDetails()); + NotificationService::current()->Notify( + NOTIFICATION_RENDER_VIEW_HOST_DELETED, + Source<RenderViewHost>(this), + NotificationService::NoDetails()); ClearPowerSaveBlockers(); @@ -215,11 +212,11 @@ RenderViewHostImpl::~RenderViewHostImpl() { GetProcess()->GetID(), GetRoutingID(), false); } -content::RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { +RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { return delegate_; } -content::SiteInstance* RenderViewHostImpl::GetSiteInstance() const { +SiteInstance* RenderViewHostImpl::GetSiteInstance() const { return instance_; } @@ -280,7 +277,7 @@ bool RenderViewHostImpl::CreateRenderView( delegate_->RenderViewCreated(this); FOR_EACH_OBSERVER( - content::RenderViewHostObserver, observers_, RenderViewHostInitialized()); + RenderViewHostObserver, observers_, RenderViewHostInitialized()); return true; } @@ -339,8 +336,7 @@ void RenderViewHostImpl::Navigate(const ViewMsg_Navigate_Params& params) { if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) delegate_->DidStartLoading(this); - FOR_EACH_OBSERVER(content::RenderViewHostObserver, - observers_, Navigate(params.url)); + FOR_EACH_OBSERVER(RenderViewHostObserver, observers_, Navigate(params.url)); } void RenderViewHostImpl::NavigateToURL(const GURL& url) { @@ -350,7 +346,7 @@ void RenderViewHostImpl::NavigateToURL(const GURL& url) { params.current_history_list_offset = -1; params.current_history_list_length = 0; params.url = url; - params.transition = content::PAGE_TRANSITION_LINK; + params.transition = PAGE_TRANSITION_LINK; params.navigation_type = ViewMsg_Navigate_Type::NORMAL; Navigate(params); } @@ -481,12 +477,12 @@ void RenderViewHostImpl::WasSwappedOut() { // Count the number of widget hosts for the process, which is equivalent to // views using the process as of this writing. - content::RenderProcessHost::RenderWidgetHostsIterator iter( + RenderProcessHost::RenderWidgetHostsIterator iter( GetProcess()->GetRenderWidgetHostsIterator()); for (; !iter.IsAtEnd(); iter.Advance()) ++views; - if (!content::RenderProcessHost::run_renderer_in_process() && + if (!RenderProcessHost::run_renderer_in_process() && process_handle && views <= 1) { // The process can safely be terminated, only if WebContents sets // SuddenTerminationAllowed, which indicates that the timer has expired. @@ -527,10 +523,10 @@ void RenderViewHostImpl::ClosePage() { // TODO(creis): Should this be moved to Shutdown? It may not be called for // RenderViewHosts that have been swapped out. - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, - content::Source<RenderViewHost>(this), - content::NotificationService::NoDetails()); + NotificationService::current()->Notify( + NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, + Source<RenderViewHost>(this), + NotificationService::NoDetails()); Send(new ViewMsg_ClosePage(GetRoutingID())); } else { @@ -730,10 +726,10 @@ ExecuteNotificationObserver::~ExecuteNotificationObserver() { } void ExecuteNotificationObserver::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - content::Details<ExecuteDetailType> execute_details = - static_cast<content::Details<ExecuteDetailType> >(details); + const NotificationSource& source, + const NotificationDetails& details) { + Details<ExecuteDetailType> execute_details = + static_cast<Details<ExecuteDetailType> >(details); int id = execute_details->first; if (id != id_) return; @@ -748,10 +744,10 @@ Value* RenderViewHostImpl::ExecuteJavascriptAndGetValue( const string16& jscript) { int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript); ExecuteNotificationObserver observer(id); - content::NotificationRegistrar notification_registrar; + NotificationRegistrar notification_registrar; notification_registrar.Add( - &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, - content::Source<RenderViewHost>(this)); + &observer, NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, + Source<RenderViewHost>(this)); MessageLoop* loop = MessageLoop::current(); loop->Run(); return observer.value()->DeepCopy(); @@ -813,7 +809,7 @@ void RenderViewHostImpl::DragSourceSystemDragEnded() { void RenderViewHostImpl::AllowBindings(int bindings_flags) { // Ensure we aren't granting WebUI bindings to a process that has already // been used for non-privileged views. - if (bindings_flags & content::BINDINGS_POLICY_WEB_UI && + if (bindings_flags & BINDINGS_POLICY_WEB_UI && GetProcess()->HasConnection() && !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( GetProcess()->GetID())) { @@ -825,7 +821,7 @@ void RenderViewHostImpl::AllowBindings(int bindings_flags) { return; } - if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) { + if (bindings_flags & BINDINGS_POLICY_WEB_UI) { ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings( GetProcess()->GetID()); } @@ -844,7 +840,7 @@ void RenderViewHostImpl::SetWebUIProperty(const std::string& name, // This is just a sanity check before telling the renderer to enable the // property. It could lie and send the corresponding IPC messages anyway, // but we will not act on them if enabled_bindings_ doesn't agree. - if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) + if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value)); else NOTREACHED() << "WebUI bindings not enabled."; @@ -931,7 +927,7 @@ bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { // Filter out most IPC messages if this renderer is swapped out. // We still want to handle certain ACKs to keep our state consistent. if (is_swapped_out_) { - if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { + if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { // If this is a synchronous message and we decided not to handle it, // we must send an error reply, or else the renderer will be stuck // and won't respond to future requests. @@ -945,8 +941,8 @@ bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { } } - ObserverListBase<content::RenderViewHostObserver>::Iterator it(observers_); - content::RenderViewHostObserver* observer; + ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); + RenderViewHostObserver* observer; while ((observer = it.GetNext()) != NULL) { if (observer->OnMessageReceived(msg)) return true; @@ -1051,7 +1047,7 @@ bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { if (!msg_is_ok) { // The message had a handler, but its de-serialization failed. // Kill the renderer. - content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); + RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); GetProcess()->ReceivedBadMessage(); } @@ -1126,7 +1122,7 @@ void RenderViewHostImpl::OnMsgRunModal(int opener_id, IPC::Message* reply_msg) { run_modal_reply_msg_ = reply_msg; run_modal_opener_id_ = opener_id; - content::RecordAction(UserMetricsAction("ShowModalDialog")); + RecordAction(UserMetricsAction("ShowModalDialog")); RenderViewHostImpl* opener = RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_); @@ -1213,7 +1209,7 @@ void RenderViewHostImpl::OnMsgNavigate(const IPC::Message& msg) { // to allow the pending navigation to continue. if (is_waiting_for_beforeunload_ack_ && unload_ack_is_for_cross_site_transition_ && - content::PageTransitionIsMainFrame(validated_params.transition)) { + PageTransitionIsMainFrame(validated_params.transition)) { OnMsgShouldCloseACK(true, send_should_close_start_time_, base::TimeTicks::Now()); return; @@ -1262,7 +1258,7 @@ void RenderViewHostImpl::OnMsgUpdateTitle( int32 page_id, const string16& title, WebKit::WebTextDirection title_direction) { - if (title.length() > content::kMaxTitleChars) { + if (title.length() > kMaxTitleChars) { NOTREACHED() << "Renderer sent too many characters in title."; return; } @@ -1288,7 +1284,7 @@ void RenderViewHostImpl::OnMsgUpdateTargetURL(int32 page_id, void RenderViewHostImpl::OnUpdateInspectorSetting( const std::string& key, const std::string& value) { - content::GetContentClient()->browser()->UpdateInspectorSetting( + GetContentClient()->browser()->UpdateInspectorSetting( this, key, value); } @@ -1325,11 +1321,10 @@ void RenderViewHostImpl::OnMsgDocumentOnLoadCompletedInMainFrame( delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id); } -void RenderViewHostImpl::OnMsgContextMenu( - const content::ContextMenuParams& params) { +void RenderViewHostImpl::OnMsgContextMenu(const ContextMenuParams& params) { // Validate the URLs in |params|. If the renderer can't request the URLs // directly, don't show them in the context menu. - content::ContextMenuParams validated_params(params); + ContextMenuParams validated_params(params); int renderer_id = GetProcess()->GetID(); ChildProcessSecurityPolicyImpl* policy = ChildProcessSecurityPolicyImpl::GetInstance(); @@ -1341,13 +1336,13 @@ void RenderViewHostImpl::OnMsgContextMenu( FilterURL(policy, renderer_id, false, &validated_params.page_url); FilterURL(policy, renderer_id, true, &validated_params.frame_url); - content::ContextMenuSourceType type = content::CONTEXT_MENU_SOURCE_MOUSE; + ContextMenuSourceType type = CONTEXT_MENU_SOURCE_MOUSE; if (!in_process_event_types_.empty()) { WebKit::WebInputEvent::Type event_type = in_process_event_types_.front(); if (WebKit::WebInputEvent::isGestureEventType(event_type)) - type = content::CONTEXT_MENU_SOURCE_TOUCH; + type = CONTEXT_MENU_SOURCE_TOUCH; else if (WebKit::WebInputEvent::isKeyboardEventType(event_type)) - type = content::CONTEXT_MENU_SOURCE_KEYBOARD; + type = CONTEXT_MENU_SOURCE_KEYBOARD; } delegate_->ShowContextMenu(validated_params, type); } @@ -1359,7 +1354,7 @@ void RenderViewHostImpl::OnMsgToggleFullscreen(bool enter_fullscreen) { } void RenderViewHostImpl::OnMsgOpenURL(const GURL& url, - const content::Referrer& referrer, + const Referrer& referrer, WindowOpenDisposition disposition, int64 source_frame_id) { GURL validated_url(url); @@ -1427,7 +1422,7 @@ void RenderViewHostImpl::OnMsgRunJavaScriptMessage( const string16& message, const string16& default_prompt, const GURL& frame_url, - content::JavaScriptMessageType type, + JavaScriptMessageType type, IPC::Message* reply_msg) { // While a JS message dialog is showing, tabs in the same process shouldn't // process input events. @@ -1482,7 +1477,7 @@ void RenderViewHostImpl::OnMsgStartDragging( if (policy->CanReadFile(GetProcess()->GetID(), path)) filtered_data.filenames.push_back(*it); } - ui::ScaleFactor scale_factor = content::GetScaleFactorForView(GetView()); + ui::ScaleFactor scale_factor = GetScaleFactorForView(GetView()); gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale_factor)); view->StartDragging(filtered_data, drag_operations_mask, image, bitmap_offset_in_dip); @@ -1495,10 +1490,10 @@ void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { } void RenderViewHostImpl::OnTargetDropACK() { - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, - content::Source<RenderViewHost>(this), - content::NotificationService::NoDetails()); + NotificationService::current()->Notify( + NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, + Source<RenderViewHost>(this), + NotificationService::NoDetails()); } void RenderViewHostImpl::OnTakeFocus(bool reverse) { @@ -1508,10 +1503,10 @@ void RenderViewHostImpl::OnTakeFocus(bool reverse) { } void RenderViewHostImpl::OnFocusedNodeChanged(bool is_editable_node) { - content::NotificationService::current()->Notify( - content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, - content::Source<RenderViewHost>(this), - content::Details<const bool>(&is_editable_node)); + NotificationService::current()->Notify( + NOTIFICATION_FOCUS_CHANGED_IN_PAGE, + Source<RenderViewHost>(this), + Details<const bool>(&is_editable_node)); } void RenderViewHostImpl::OnAddMessageToConsole( @@ -1523,19 +1518,17 @@ void RenderViewHostImpl::OnAddMessageToConsole( return; // Pass through log level only on WebUI pages to limit console spew. int32 resolved_level = - (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0; + (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) ? level : 0; logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" << message << "\", source: " << source_id << " (" << line_no << ")"; } -void RenderViewHostImpl::AddObserver( - content::RenderViewHostObserver* observer) { +void RenderViewHostImpl::AddObserver(RenderViewHostObserver* observer) { observers_.AddObserver(observer); } -void RenderViewHostImpl::RemoveObserver( - content::RenderViewHostObserver* observer) { +void RenderViewHostImpl::RemoveObserver(RenderViewHostObserver* observer) { observers_.RemoveObserver(observer); } @@ -1568,7 +1561,7 @@ void RenderViewHostImpl::OnMsgShouldCloseACK( // for any skew between the processes. Here we are converting the // renderer's notion of before_unload_end_time to TimeTicks in the browser // process. See comments in inter_process_time_ticks_converter.h for more. - content::InterProcessTimeTicksConverter converter( + InterProcessTimeTicksConverter converter( LocalTimeTicks::FromTimeTicks(send_should_close_start_time_), LocalTimeTicks::FromTimeTicks(base::TimeTicks::Now()), RemoteTimeTicks::FromTimeTicks(renderer_before_unload_start_time), @@ -1781,7 +1774,7 @@ void RenderViewHostImpl::SetZoomLevel(double level) { Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level)); } -void RenderViewHostImpl::Zoom(content::PageZoom zoom) { +void RenderViewHostImpl::Zoom(PageZoom zoom) { Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); } @@ -1820,12 +1813,12 @@ void RenderViewHostImpl::DisableAutoResize(const gfx::Size& new_size) { } void RenderViewHostImpl::ExecuteCustomContextMenuCommand( - int action, const content::CustomContextMenuContext& context) { + int action, const CustomContextMenuContext& context) { Send(new ViewMsg_CustomContextMenuAction(GetRoutingID(), context, action)); } void RenderViewHostImpl::NotifyContextMenuClosed( - const content::CustomContextMenuContext& context) { + const CustomContextMenuContext& context) { Send(new ViewMsg_ContextMenuClosed(GetRoutingID(), context)); } @@ -1851,7 +1844,7 @@ void RenderViewHostImpl::NotifyMoveOrResizeStarted() { Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); } -void RenderViewHostImpl::StopFinding(content::StopFindAction action) { +void RenderViewHostImpl::StopFinding(StopFindAction action) { Send(new ViewMsg_StopFinding(GetRoutingID(), action)); } @@ -1872,15 +1865,15 @@ void RenderViewHostImpl::OnAccessibilityNotifications( NotificationType dst_type; if (src_type == AccessibilityNotificationLoadComplete) - dst_type = content::NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE; + dst_type = NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE; else if (src_type == AccessibilityNotificationLayoutComplete) - dst_type = content::NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE; + dst_type = NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE; else - dst_type = content::NOTIFICATION_ACCESSIBILITY_OTHER; - content::NotificationService::current()->Notify( + dst_type = NOTIFICATION_ACCESSIBILITY_OTHER; + NotificationService::current()->Notify( dst_type, - content::Source<RenderViewHost>(this), - content::NotificationService::NoDetails()); + Source<RenderViewHost>(this), + NotificationService::NoDetails()); } Send(new AccessibilityMsg_Notifications_ACK(GetRoutingID())); @@ -1894,10 +1887,10 @@ void RenderViewHostImpl::OnScriptEvalResponse(int id, const ListValue& result) { return; } std::pair<int, const Value*> details(id, result_value); - content::NotificationService::current()->Notify( - content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, - content::Source<RenderViewHost>(this), - content::Details<std::pair<int, const Value*> >(&details)); + NotificationService::current()->Notify( + NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, + Source<RenderViewHost>(this), + Details<std::pair<int, const Value*> >(&details)); } void RenderViewHostImpl::OnDidZoomURL(double zoom_level, @@ -1946,12 +1939,12 @@ void RenderViewHostImpl::OnStartContentIntent(const GURL& content_url) { void RenderViewHostImpl::OnRequestDesktopNotificationPermission( const GURL& source_origin, int callback_context) { - content::GetContentClient()->browser()->RequestDesktopNotificationPermission( + GetContentClient()->browser()->RequestDesktopNotificationPermission( source_origin, callback_context, GetProcess()->GetID(), GetRoutingID()); } void RenderViewHostImpl::OnShowDesktopNotification( - const content::ShowDesktopNotificationHostMsgParams& params) { + const ShowDesktopNotificationHostMsgParams& params) { // Disallow HTML notifications from javascript: and file: schemes as this // allows unwanted cross-domain access. GURL url = params.contents_url; @@ -1961,12 +1954,12 @@ void RenderViewHostImpl::OnShowDesktopNotification( return; } - content::GetContentClient()->browser()->ShowDesktopNotification( + GetContentClient()->browser()->ShowDesktopNotification( params, GetProcess()->GetID(), GetRoutingID(), false); } void RenderViewHostImpl::OnCancelDesktopNotification(int notification_id) { - content::GetContentClient()->browser()->CancelDesktopNotification( + GetContentClient()->browser()->CancelDesktopNotification( GetProcess()->GetID(), GetRoutingID(), notification_id); } @@ -1986,18 +1979,17 @@ void RenderViewHostImpl::OnMsgShowPopup( } #endif -void RenderViewHostImpl::OnRunFileChooser( - const content::FileChooserParams& params) { +void RenderViewHostImpl::OnRunFileChooser(const FileChooserParams& params) { delegate_->RunFileChooser(this, params); } void RenderViewHostImpl::OnDomOperationResponse( const std::string& json_string, int automation_id) { DomOperationNotificationDetails details(json_string, automation_id); - content::NotificationService::current()->Notify( - content::NOTIFICATION_DOM_OPERATION_RESPONSE, - content::Source<RenderViewHost>(this), - content::Details<DomOperationNotificationDetails>(&details)); + NotificationService::current()->Notify( + NOTIFICATION_DOM_OPERATION_RESPONSE, + Source<RenderViewHost>(this), + Details<DomOperationNotificationDetails>(&details)); } void RenderViewHostImpl::OnFrameTreeUpdated(const std::string& frame_tree) { diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 565c9d1..8f09fda 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -47,7 +47,7 @@ namespace { // Returns the resource response header structure for this request. void GetResponseHead(const std::vector<IPC::Message>& messages, - content::ResourceResponseHead* response_head) { + ResourceResponseHead* response_head) { ASSERT_GE(messages.size(), 2U); // The first messages should be received response. @@ -103,7 +103,7 @@ static ResourceHostMsg_Request CreateResourceRequest( request.frame_id = 0; request.parent_is_main_frame = false; request.parent_frame_id = -1; - request.transition_type = content::PAGE_TRANSITION_LINK; + request.transition_type = PAGE_TRANSITION_LINK; request.allow_download = true; return request; } @@ -179,10 +179,10 @@ class MockURLRequestContextSelector class ForwardingFilter : public ResourceMessageFilter { public: explicit ForwardingFilter(IPC::Sender* dest, - content::ResourceContext* resource_context) + ResourceContext* resource_context) : ResourceMessageFilter( ChildProcessHostImpl::GenerateChildProcessUniqueId(), - content::PROCESS_TYPE_RENDERER, + PROCESS_TYPE_RENDERER, resource_context, NULL, NULL, new MockURLRequestContextSelector( resource_context->GetRequestContext())), @@ -395,7 +395,7 @@ enum GenericResourceThrottleFlags { // Throttle that tracks the current throttle blocking a request. Only one // can throttle any request at a time. -class GenericResourceThrottle : public content::ResourceThrottle { +class GenericResourceThrottle : public ResourceThrottle { public: explicit GenericResourceThrottle(int flags) : flags_(flags) { @@ -406,7 +406,7 @@ class GenericResourceThrottle : public content::ResourceThrottle { active_throttle_ = NULL; } - // content::ResourceThrottle implementation: + // ResourceThrottle implementation: virtual void WillStartRequest(bool* defer) OVERRIDE { ASSERT_EQ(NULL, active_throttle_); if (flags_ & DEFER_STARTING_REQUEST) { @@ -447,7 +447,7 @@ class GenericResourceThrottle : public content::ResourceThrottle { GenericResourceThrottle* GenericResourceThrottle::active_throttle_ = NULL; class TestResourceDispatcherHostDelegate - : public content::ResourceDispatcherHostDelegate { + : public ResourceDispatcherHostDelegate { public: TestResourceDispatcherHostDelegate() : create_two_throttles_(false), @@ -470,13 +470,13 @@ class TestResourceDispatcherHostDelegate virtual void RequestBeginning( net::URLRequest* request, - content::ResourceContext* resource_context, + ResourceContext* resource_context, appcache::AppCacheService* appcache_service, ResourceType::Type resource_type, int child_id, int route_id, bool is_continuation_of_transferred_request, - ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE { + ScopedVector<ResourceThrottle>* throttles) OVERRIDE { if (user_data_.get()) { const void* key = user_data_.get(); request->SetUserData(key, user_data_.release()); @@ -506,7 +506,7 @@ class ResourceDispatcherHostTest : public testing::Test, old_factory_(NULL), resource_type_(ResourceType::SUB_RESOURCE), send_data_received_acks_(false) { - browser_context_.reset(new content::TestBrowserContext()); + browser_context_.reset(new TestBrowserContext()); BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); message_loop_.RunAllPending(); filter_ = new ForwardingFilter( @@ -684,7 +684,7 @@ class ResourceDispatcherHostTest : public testing::Test, BrowserThreadImpl file_thread_; BrowserThreadImpl cache_thread_; BrowserThreadImpl io_thread_; - scoped_ptr<content::TestBrowserContext> browser_context_; + scoped_ptr<TestBrowserContext> browser_context_; scoped_refptr<ForwardingFilter> filter_; ResourceDispatcherHostImpl host_; ResourceIPCAccumulator accum_; @@ -973,7 +973,7 @@ TEST_F(ResourceDispatcherHostTest, ThrottleAndResumeTwice) { // pending and some canceled. class TestFilter : public ForwardingFilter { public: - explicit TestFilter(content::ResourceContext* resource_context) + explicit TestFilter(ResourceContext* resource_context) : ForwardingFilter(NULL, resource_context), has_canceled_(false), received_after_canceled_(0) { @@ -1383,7 +1383,7 @@ TEST_F(ResourceDispatcherHostTest, MimeSniffed) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - content::ResourceResponseHead response_head; + ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("text/html", response_head.mime_type); } @@ -1410,7 +1410,7 @@ TEST_F(ResourceDispatcherHostTest, MimeNotSniffed) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - content::ResourceResponseHead response_head; + ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("image/jpeg", response_head.mime_type); } @@ -1435,7 +1435,7 @@ TEST_F(ResourceDispatcherHostTest, MimeNotSniffed2) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - content::ResourceResponseHead response_head; + ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("", response_head.mime_type); } @@ -1458,7 +1458,7 @@ TEST_F(ResourceDispatcherHostTest, MimeSniff204) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - content::ResourceResponseHead response_head; + ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("text/plain", response_head.mime_type); } @@ -1481,7 +1481,7 @@ TEST_F(ResourceDispatcherHostTest, MimeSniffEmpty) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - content::ResourceResponseHead response_head; + ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("text/plain", response_head.mime_type); } diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.h b/content/browser/renderer_host/socket_stream_dispatcher_host.h index 71901f3..4709227 100644 --- a/content/browser/renderer_host/socket_stream_dispatcher_host.h +++ b/content/browser/renderer_host/socket_stream_dispatcher_host.h @@ -15,7 +15,6 @@ #include "net/socket_stream/socket_stream.h" class GURL; -class SocketStreamHost; namespace net { class SSLInfo; @@ -23,6 +22,7 @@ class SSLInfo; namespace content { class ResourceContext; +class SocketStreamHost; // Dispatches ViewHostMsg_SocketStream_* messages sent from renderer. // It also acts as SocketStream::Delegate so that it sends diff --git a/content/browser/renderer_host/socket_stream_host.cc b/content/browser/renderer_host/socket_stream_host.cc index 540a38a..3cba3a0 100644 --- a/content/browser/renderer_host/socket_stream_host.cc +++ b/content/browser/renderer_host/socket_stream_host.cc @@ -8,7 +8,10 @@ #include "content/common/socket_stream.h" #include "net/socket_stream/socket_stream_job.h" -static const char* kSocketIdKey = "socketId"; +namespace content { +namespace { + +const char* kSocketIdKey = "socketId"; class SocketStreamId : public net::SocketStream::UserData { public: @@ -20,6 +23,8 @@ class SocketStreamId : public net::SocketStream::UserData { int socket_id_; }; +} // namespace + SocketStreamHost::SocketStreamHost( net::SocketStream::Delegate* delegate, int render_view_id, @@ -27,7 +32,7 @@ SocketStreamHost::SocketStreamHost( : delegate_(delegate), render_view_id_(render_view_id), socket_id_(socket_id) { - DCHECK_NE(socket_id_, content::kNoSocketId); + DCHECK_NE(socket_id_, kNoSocketId); VLOG(1) << "SocketStreamHost: render_view_id=" << render_view_id << " socket_id=" << socket_id_; } @@ -39,7 +44,7 @@ int SocketStreamHost::SocketIdFromSocketStream(net::SocketStream* socket) { SocketStreamId* socket_stream_id = static_cast<SocketStreamId*>(d); return socket_stream_id->socket_id(); } - return content::kNoSocketId; + return kNoSocketId; } SocketStreamHost::~SocketStreamHost() { @@ -90,3 +95,5 @@ void SocketStreamHost::ContinueDespiteError() { return; socket_->ContinueDespiteError(); } + +} // namespace content diff --git a/content/browser/renderer_host/socket_stream_host.h b/content/browser/renderer_host/socket_stream_host.h index 274ed6d..d0c65ab 100644 --- a/content/browser/renderer_host/socket_stream_host.h +++ b/content/browser/renderer_host/socket_stream_host.h @@ -18,13 +18,13 @@ class URLRequestContext; class SSLInfo; } // namespace net -// Host of SocketStreamHandle. -// Each SocketStreamHandle will have an unique socket_id assigned by -// SocketStreamHost constructor. If socket id is content::kNoSocketId, -// there is no SocketStreamHost. -// Each SocketStreamHost has SocketStream to manage bi-directional -// communication over socket stream. -// The lifetime of an instance of this class is completely controlled by the +namespace content { + +// Host of SocketStreamHandle. Each SocketStreamHandle will have an unique +// socket_id assigned by SocketStreamHost constructor. If socket id is +// kNoSocketId, there is no SocketStreamHost. Each SocketStreamHost has +// SocketStream to manage bi-directional communication over socket stream. The +// lifetime of an instance of this class is completely controlled by the // SocketStreamDispatcherHost. class SocketStreamHost { public: @@ -74,4 +74,6 @@ class SocketStreamHost { DISALLOW_COPY_AND_ASSIGN(SocketStreamHost); }; +} // namespace content + #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ diff --git a/content/browser/worker_host/test/worker_browsertest.cc b/content/browser/worker_host/test/worker_browsertest.cc index c37a187..dc3096f 100644 --- a/content/browser/worker_host/test/worker_browsertest.cc +++ b/content/browser/worker_host/test/worker_browsertest.cc @@ -25,8 +25,7 @@ #include "googleurl/src/gurl.h" #include "net/test/test_server.h" -using content::BrowserThread; -using content::WorkerServiceImpl; +namespace content { class WorkerLayoutTest : public InProcessBrowserLayoutTest { public: @@ -222,23 +221,23 @@ IN_PROC_BROWSER_TEST_F(WorkerXHRHttpLayoutTest, Tests) { RunHttpLayoutTest(kLayoutTestFiles[i]); } -class WorkerTest : public content::ContentBrowserTest { +class WorkerTest : public ContentBrowserTest { public: WorkerTest() {} GURL GetTestURL(const std::string& test_case, const std::string& query) { - FilePath test_file_path = content::GetTestFilePath( + FilePath test_file_path = GetTestFilePath( "workers", test_case.c_str()); - return content::GetFileUrlWithQuery(test_file_path, query); + return GetFileUrlWithQuery(test_file_path, query); } - void RunTest(content::Shell* window, + void RunTest(Shell* window, const std::string& test_case, const std::string& query) { GURL url = GetTestURL(test_case, query); const string16 expected_title = ASCIIToUTF16("OK"); - content::TitleWatcher title_watcher(window->web_contents(), expected_title); - content::NavigateToURL(window, url); + TitleWatcher title_watcher(window->web_contents(), expected_title); + NavigateToURL(window, url); string16 final_title = title_watcher.WaitAndGetTitle(); EXPECT_EQ(expected_title, final_title); } @@ -262,7 +261,7 @@ class WorkerTest : public content::ContentBrowserTest { BrowserThread::IO, FROM_HERE, base::Bind(&CountWorkerProcesses, &cur_process_count)); - content::RunMessageLoop(); + RunMessageLoop(); if (cur_process_count == count) return true; @@ -280,11 +279,9 @@ class WorkerTest : public content::ContentBrowserTest { } void NavigateAndWaitForAuth(const GURL& url) { - content::ShellContentBrowserClient* browser_client = - static_cast<content::ShellContentBrowserClient*>( - content::GetContentClient()->browser()); - scoped_refptr<content::MessageLoopRunner> runner = - new content::MessageLoopRunner(); + ShellContentBrowserClient* browser_client = + static_cast<ShellContentBrowserClient*>(GetContentClient()->browser()); + scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); browser_client->resource_dispatcher_host_delegate()-> set_login_request_callback( base::Bind(&QuitUIMessageLoop, runner->QuitClosure())); @@ -348,7 +345,7 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, LimitPerPage) { std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); GURL url = GetTestURL("many_shared_workers.html", query); - content::NavigateToURL(shell(), url); + NavigateToURL(shell(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); } @@ -370,13 +367,12 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, LimitTotal) { std::string query = StringPrintf("?count=%d", max_workers_per_tab); GURL url = GetTestURL("many_shared_workers.html", query); - content::NavigateToURL( - shell(), GURL(url.spec() + StringPrintf("&client_id=0"))); + NavigateToURL(shell(), GURL(url.spec() + StringPrintf("&client_id=0"))); // Adding 1 so that we cause some workers to be queued. int tab_count = (total_workers / max_workers_per_tab) + 1; for (int i = 1; i < tab_count; ++i) { - content::NavigateToURL( + NavigateToURL( CreateBrowser(), GURL(url.spec() + StringPrintf("&client_id=%d", i))); } @@ -384,8 +380,8 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, LimitTotal) { ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); // Now close a page and check that the queued workers were started. - url = GURL(content::GetTestUrl("google", "google.html")); - content::NavigateToURL(shell(), url); + url = GURL(GetTestUrl("google", "google.html")); + NavigateToURL(shell(), url); ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); } @@ -415,19 +411,19 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_MultipleTabsQueuedSharedWorker) { int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); GURL url = GetTestURL("many_shared_workers.html", query); - content::NavigateToURL(shell(), url); + NavigateToURL(shell(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); // Create same set of workers in new tab (leaves one worker queued from this // tab). url = GetTestURL("many_shared_workers.html", query); - content::NavigateToURL(CreateBrowser(), url); + NavigateToURL(CreateBrowser(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); // Now shutdown one of the shared workers - this will fire both queued // workers, but only one instance should be started. url = GetTestURL("shutdown_shared_worker.html", "?id=0"); - content::NavigateToURL(CreateBrowser(), url); + NavigateToURL(CreateBrowser(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); } @@ -438,7 +434,7 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTa int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); GURL url = GetTestURL("many_shared_workers.html", query); - content::NavigateToURL(shell(), url); + NavigateToURL(shell(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); // First window has hit its limit. Now launch second window which creates @@ -446,7 +442,7 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTa // connected to the first window too. query = StringPrintf("?id=%d", max_workers_per_tab); url = GetTestURL("single_shared_worker.html", query); - content::NavigateToURL(CreateBrowser(), url); + NavigateToURL(CreateBrowser(), url); ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); } @@ -466,10 +462,12 @@ IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { "websocket_shared_worker.html").ReplaceComponents(replacements); // Run test. - content::Shell* window = shell(); + Shell* window = shell(); const string16 expected_title = ASCIIToUTF16("OK"); - content::TitleWatcher title_watcher(window->web_contents(), expected_title); - content::NavigateToURL(window, url); + TitleWatcher title_watcher(window->web_contents(), expected_title); + NavigateToURL(window, url); string16 final_title = title_watcher.WaitAndGetTitle(); EXPECT_EQ(expected_title, final_title); } + +} // namespace content diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index b576295..c5d46eb 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -52,17 +52,7 @@ #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/glue/resource_type.h" -using content::BrowserThread; -using content::ChildProcessData; -using content::ChildProcessHost; -using content::RenderViewHostImpl; -using content::ResourceContext; -using content::ResourceMessageFilter; -using content::SocketStreamDispatcherHost; -using content::UserMetricsAction; -using content::WorkerDevToolsManager; -using content::WorkerServiceImpl; - +namespace content { namespace { // Helper class that we pass to SocketStreamDispatcherHost so that it can find @@ -108,7 +98,7 @@ WorkerProcessHost::WorkerProcessHost( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(resource_context_); process_.reset( - new BrowserChildProcessHostImpl(content::PROCESS_TYPE_WORKER, this)); + new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); } WorkerProcessHost::~WorkerProcessHost() { @@ -153,8 +143,7 @@ bool WorkerProcessHost::Init(int render_process_id) { CommandLine* cmd_line = new CommandLine(exe_path); cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kWorkerProcess); cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); - std::string locale = - content::GetContentClient()->browser()->GetApplicationLocale(); + std::string locale = GetContentClient()->browser()->GetApplicationLocale(); cmd_line->AppendSwitchASCII(switches::kLang, locale); static const char* const kSwitchNames[] = { @@ -258,8 +247,7 @@ bool WorkerProcessHost::Init(int render_process_id) { void WorkerProcessHost::CreateMessageFilters(int render_process_id) { ChromeBlobStorageContext* blob_storage_context = - content::GetChromeBlobStorageContextForResourceContext( - resource_context_); + GetChromeBlobStorageContextForResourceContext(resource_context_); net::URLRequestContextGetter* url_request_context = partition_.url_request_context(); @@ -267,7 +255,7 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { partition_.url_request_context(); ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( - process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, + process_->GetData().id, PROCESS_TYPE_WORKER, resource_context_, partition_.appcache_service(), blob_storage_context, new URLRequestContextSelector(url_request_context, @@ -301,7 +289,7 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { resource_context_); process_->GetHost()->AddFilter(socket_stream_dispatcher_host); process_->GetHost()->AddFilter( - new content::WorkerDevToolsMessageFilter(process_->GetData().id)); + new WorkerDevToolsMessageFilter(process_->GetData().id)); process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( process_->GetData().id, partition_.indexed_db_context())); } @@ -362,10 +350,9 @@ bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { if (!msg_is_ok) { NOTREACHED(); - content::RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); + RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); base::KillProcess( - process_->GetData().handle, content::RESULT_CODE_KILLED_BAD_MESSAGE, - false); + process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); } if (handled) @@ -408,7 +395,7 @@ void WorkerProcessHost::OnAllowDatabase(int worker_route_id, const string16& display_name, unsigned long estimated_size, bool* result) { - *result = content::GetContentClient()->browser()->AllowWorkerDatabase( + *result = GetContentClient()->browser()->AllowWorkerDatabase( url, name, display_name, estimated_size, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); } @@ -416,7 +403,7 @@ void WorkerProcessHost::OnAllowDatabase(int worker_route_id, void WorkerProcessHost::OnAllowFileSystem(int worker_route_id, const GURL& url, bool* result) { - *result = content::GetContentClient()->browser()->AllowWorkerFileSystem( + *result = GetContentClient()->browser()->AllowWorkerFileSystem( url, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); } @@ -424,7 +411,7 @@ void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, const GURL& url, const string16& name, bool* result) { - *result = content::GetContentClient()->browser()->AllowWorkerIndexedDB( + *result = GetContentClient()->browser()->AllowWorkerIndexedDB( url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); } @@ -518,7 +505,7 @@ void WorkerProcessHost::UpdateTitle() { std::set<std::string> titles; for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { // Allow the embedder first crack at special casing the title. - std::string title = content::GetContentClient()->browser()-> + std::string title = GetContentClient()->browser()-> GetWorkerProcessTitle(i->url(), resource_context_); if (title.empty()) { @@ -595,7 +582,7 @@ WorkerProcessHost::WorkerInstance::WorkerInstance( int worker_route_id, int parent_process_id, int64 main_resource_appcache_id, - content::ResourceContext* resource_context, + ResourceContext* resource_context, const WorkerStoragePartition& partition) : url_(url), closed_(false), @@ -613,7 +600,7 @@ WorkerProcessHost::WorkerInstance::WorkerInstance( const GURL& url, bool shared, const string16& name, - content::ResourceContext* resource_context, + ResourceContext* resource_context, const WorkerStoragePartition& partition) : url_(url), closed_(false), @@ -639,7 +626,7 @@ bool WorkerProcessHost::WorkerInstance::Matches( const GURL& match_url, const string16& match_name, const WorkerStoragePartition& partition, - content::ResourceContext* resource_context) const { + ResourceContext* resource_context) const { // Only match open shared workers. if (closed_) return false; @@ -724,3 +711,5 @@ WorkerProcessHost::WorkerInstance::GetFilter() const { DCHECK(NumFilters() == 1); return *filters_.begin(); } + +} // namespace content diff --git a/content/browser/worker_host/worker_process_host.h b/content/browser/worker_host/worker_process_host.h index 61ea8c0..1fde05a 100644 --- a/content/browser/worker_host/worker_process_host.h +++ b/content/browser/worker_host/worker_process_host.h @@ -24,11 +24,6 @@ class BrowserChildProcessHostImpl; class ChromeAppCacheService; class IndexedDBContextImpl; -namespace content { -class ResourceContext; -class WorkerServiceImpl; -} // namespace content - namespace fileapi { class FileSystemContext; } // namespace fileapi @@ -37,13 +32,17 @@ namespace webkit_database { class DatabaseTracker; } // namespace webkit_database +namespace content { +class ResourceContext; +class WorkerServiceImpl; + // The WorkerProcessHost is the interface that represents the browser side of // the browser <-> worker communication channel. There will be one // WorkerProcessHost per worker process. Currently each worker runs in its own // process, but that may change. However, we do assume (by storing a // net::URLRequestContext) that a WorkerProcessHost serves a single // BrowserContext. -class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, +class WorkerProcessHost : public BrowserChildProcessHostDelegate, public IPC::Sender { public: // Contains information about each worker instance, needed to forward messages @@ -55,13 +54,13 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, int worker_route_id, int parent_process_id, int64 main_resource_appcache_id, - content::ResourceContext* resource_context, + ResourceContext* resource_context, const WorkerStoragePartition& partition); // Used for pending instances. Rest of the parameters are ignored. WorkerInstance(const GURL& url, bool shared, const string16& name, - content::ResourceContext* resource_context, + ResourceContext* resource_context, const WorkerStoragePartition& partition); ~WorkerInstance(); @@ -88,7 +87,7 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, const GURL& url, const string16& name, const WorkerStoragePartition& partition, - content::ResourceContext* resource_context) const; + ResourceContext* resource_context) const; // Shares the passed instance's WorkerDocumentSet with this instance. This // instance's current WorkerDocumentSet is dereferenced (and freed if this @@ -110,7 +109,7 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, WorkerDocumentSet* worker_document_set() const { return worker_document_set_; } - content::ResourceContext* resource_context() const { + ResourceContext* resource_context() const { return resource_context_; } const WorkerStoragePartition& partition() const { @@ -127,11 +126,11 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, int64 main_resource_appcache_id_; FilterList filters_; scoped_refptr<WorkerDocumentSet> worker_document_set_; - content::ResourceContext* const resource_context_; + ResourceContext* const resource_context_; WorkerStoragePartition partition_; }; - WorkerProcessHost(content::ResourceContext* resource_context, + WorkerProcessHost(ResourceContext* resource_context, const WorkerStoragePartition& partition); virtual ~WorkerProcessHost(); @@ -160,17 +159,17 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, // Terminates the given worker, i.e. based on a UI action. CONTENT_EXPORT void TerminateWorker(int worker_route_id); - CONTENT_EXPORT const content::ChildProcessData& GetData(); + CONTENT_EXPORT const ChildProcessData& GetData(); typedef std::list<WorkerInstance> Instances; const Instances& instances() const { return instances_; } - content::ResourceContext* resource_context() const { + ResourceContext* resource_context() const { return resource_context_; } protected: - friend class content::WorkerServiceImpl; + friend class WorkerServiceImpl; Instances& mutable_instances() { return instances_; } @@ -214,7 +213,7 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, Instances instances_; - content::ResourceContext* const resource_context_; + ResourceContext* const resource_context_; WorkerStoragePartition partition_; // A reference to the filter associated with this worker process. We need to @@ -228,12 +227,14 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, }; class WorkerProcessHostIterator - : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> { + : public BrowserChildProcessHostTypeIterator<WorkerProcessHost> { public: WorkerProcessHostIterator() - : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>( - content::PROCESS_TYPE_WORKER) { + : BrowserChildProcessHostTypeIterator<WorkerProcessHost>( + PROCESS_TYPE_WORKER) { } }; +} // namespace content + #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ |