diff options
author | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:19:23 +0000 |
---|---|---|
committer | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:19:23 +0000 |
commit | 21a40087a57e13cc9b81cb7e8064f74587dfa8a1 (patch) | |
tree | e88d44c64fcaa47a5b45533a4d6c993de770757c /chrome/browser/extensions/api/processes | |
parent | 0f75118d4799a7c5421150826eaccd1dfd253f8e (diff) | |
download | chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.zip chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.gz chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.bz2 |
Remove Profile dependency from ExtensionFunction
This instead creates new variants of ExtensionFunction for Chrome APIs,
which need Profile, and uses them for any API that needs to access
Profiles.
TBR=sky@chromium.org
BUG=297942
Review URL: https://codereview.chromium.org/35893010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/processes')
-rw-r--r-- | chrome/browser/extensions/api/processes/processes_api.cc | 39 | ||||
-rw-r--r-- | chrome/browser/extensions/api/processes/processes_api.h | 8 |
2 files changed, 29 insertions, 18 deletions
diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc index d1032f6..42a4ab9 100644 --- a/chrome/browser/extensions/api/processes/processes_api.cc +++ b/chrome/browser/extensions/api/processes/processes_api.cc @@ -551,16 +551,18 @@ bool GetProcessIdForTabFunction::RunImpl() { // which will invoke the callback once we have returned from this function. // Otherwise, wait for the notification that the task manager is done with // the data gathering. - if (ProcessesAPI::Get(profile_)->processes_event_router()-> - is_task_manager_listening()) { + if (ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->is_task_manager_listening()) { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( &GetProcessIdForTabFunction::GetProcessIdForTab, this)); } else { TaskManager::GetInstance()->model()->RegisterOnDataReadyCallback( base::Bind(&GetProcessIdForTabFunction::GetProcessIdForTab, this)); - ProcessesAPI::Get(profile_)->processes_event_router()-> - StartTaskManagerListening(); + ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->StartTaskManagerListening(); } return true; @@ -573,8 +575,13 @@ bool GetProcessIdForTabFunction::RunImpl() { void GetProcessIdForTabFunction::GetProcessIdForTab() { content::WebContents* contents = NULL; int tab_index = -1; - if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), - NULL, NULL, &contents, &tab_index)) { + if (!ExtensionTabUtil::GetTabById(tab_id_, + GetProfile(), + include_incognito(), + NULL, + NULL, + &contents, + &tab_index)) { error_ = ErrorUtils::FormatErrorMessage( extensions::tabs_constants::kTabNotFoundError, base::IntToString(tab_id_)); @@ -605,16 +612,18 @@ bool TerminateFunction::RunImpl() { // which will invoke the callback once we have returned from this function. // Otherwise, wait for the notification that the task manager is done with // the data gathering. - if (ProcessesAPI::Get(profile_)->processes_event_router()-> - is_task_manager_listening()) { + if (ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->is_task_manager_listening()) { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( &TerminateFunction::TerminateProcess, this)); } else { TaskManager::GetInstance()->model()->RegisterOnDataReadyCallback( base::Bind(&TerminateFunction::TerminateProcess, this)); - ProcessesAPI::Get(profile_)->processes_event_router()-> - StartTaskManagerListening(); + ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->StartTaskManagerListening(); } return true; @@ -685,16 +694,18 @@ bool GetProcessInfoFunction::RunImpl() { // which will invoke the callback once we have returned from this function. // Otherwise, wait for the notification that the task manager is done with // the data gathering. - if (ProcessesAPI::Get(profile_)->processes_event_router()-> - is_task_manager_listening()) { + if (ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->is_task_manager_listening()) { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( &GetProcessInfoFunction::GatherProcessInfo, this)); } else { TaskManager::GetInstance()->model()->RegisterOnDataReadyCallback( base::Bind(&GetProcessInfoFunction::GatherProcessInfo, this)); - ProcessesAPI::Get(profile_)->processes_event_router()-> - StartTaskManagerListening(); + ProcessesAPI::Get(GetProfile()) + ->processes_event_router() + ->StartTaskManagerListening(); } return true; diff --git a/chrome/browser/extensions/api/processes/processes_api.h b/chrome/browser/extensions/api/processes/processes_api.h index 21cabad..85455f9 100644 --- a/chrome/browser/extensions/api/processes/processes_api.h +++ b/chrome/browser/extensions/api/processes/processes_api.h @@ -10,8 +10,8 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" +#include "chrome/browser/extensions/chrome_extension_function.h" #include "chrome/browser/extensions/event_router.h" -#include "chrome/browser/extensions/extension_function.h" #include "chrome/browser/task_manager/task_manager.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h" #include "content/public/browser/notification_registrar.h" @@ -131,7 +131,7 @@ class ProcessesAPI : public ProfileKeyedAPI, // This extension function returns the Process object for the renderer process // currently in use by the specified Tab. -class GetProcessIdForTabFunction : public AsyncExtensionFunction { +class GetProcessIdForTabFunction : public ChromeAsyncExtensionFunction { public: GetProcessIdForTabFunction(); @@ -153,7 +153,7 @@ class GetProcessIdForTabFunction : public AsyncExtensionFunction { // Using unique IDs instead of OS process IDs allows two advantages: // * guaranteed uniqueness, since OS process IDs can be reused // * guards against killing non-Chrome processes -class TerminateFunction : public AsyncExtensionFunction { +class TerminateFunction : public ChromeAsyncExtensionFunction { public: TerminateFunction(); @@ -173,7 +173,7 @@ class TerminateFunction : public AsyncExtensionFunction { // Extension function which returns a set of Process objects, containing the // details corresponding to the process IDs supplied as input. -class GetProcessInfoFunction : public AsyncExtensionFunction { +class GetProcessInfoFunction : public ChromeAsyncExtensionFunction { public: GetProcessInfoFunction(); |