diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 10:53:25 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 10:53:25 +0000 |
commit | 7ca39f0814218a70fdb6741a7f59f7d3306879c9 (patch) | |
tree | b91c4cb9f1be4614c25948858c3324c9f2012713 /components | |
parent | 5c4a5aa24a36f6e1c17a0d703b600186e0606827 (diff) | |
download | chromium_src-7ca39f0814218a70fdb6741a7f59f7d3306879c9.zip chromium_src-7ca39f0814218a70fdb6741a7f59f7d3306879c9.tar.gz chromium_src-7ca39f0814218a70fdb6741a7f59f7d3306879c9.tar.bz2 |
Have AutofillManager obtain the blocking pool that it uses from AutofillDriver
Instead of using content::BrowserThread's global SequencedWorkerPool to execute
blocking tasks, AutofillManager now obtains a blocking pool from AutofillDriver.
BUG=303014
Review URL: https://codereview.chromium.org/26261002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
7 files changed, 38 insertions, 11 deletions
diff --git a/components/autofill/content/browser/autofill_driver_impl.cc b/components/autofill/content/browser/autofill_driver_impl.cc index 422a0e9..099a7da 100644 --- a/components/autofill/content/browser/autofill_driver_impl.cc +++ b/components/autofill/content/browser/autofill_driver_impl.cc @@ -5,12 +5,14 @@ #include "components/autofill/content/browser/autofill_driver_impl.h" #include "base/command_line.h" +#include "base/threading/sequenced_worker_pool.h" #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_manager_delegate.h" #include "components/autofill/core/common/autofill_messages.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/common/autofill_switches.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/render_view_host.h" @@ -69,6 +71,10 @@ content::WebContents* AutofillDriverImpl::GetWebContents() { return web_contents(); } +base::SequencedWorkerPool* AutofillDriverImpl::GetBlockingPool() { + return content::BrowserThread::GetBlockingPool(); +} + bool AutofillDriverImpl::RendererIsAvailable() { return (web_contents()->GetRenderViewHost() != NULL); } diff --git a/components/autofill/content/browser/autofill_driver_impl.h b/components/autofill/content/browser/autofill_driver_impl.h index 8135500..e8fe30b 100644 --- a/components/autofill/content/browser/autofill_driver_impl.h +++ b/components/autofill/content/browser/autofill_driver_impl.h @@ -43,6 +43,7 @@ class AutofillDriverImpl : public AutofillDriver, // AutofillDriver: virtual content::WebContents* GetWebContents() OVERRIDE; + virtual base::SequencedWorkerPool* GetBlockingPool() OVERRIDE; virtual bool RendererIsAvailable() OVERRIDE; virtual void SetRendererActionOnFormDataReception( RendererFormDataAction action) OVERRIDE; diff --git a/components/autofill/core/browser/DEPS b/components/autofill/core/browser/DEPS index 54efc37..9b93c76 100644 --- a/components/autofill/core/browser/DEPS +++ b/components/autofill/core/browser/DEPS @@ -13,7 +13,6 @@ include_rules = [ # Do not add to the list of temporarily-allowed dependencies below, # and please do not introduce more #includes of these files. "!content/public/browser/browser_context.h", - "!content/public/browser/browser_thread.h", "!content/public/browser/render_view_host.h", "!content/public/browser/web_contents.h", "!content/public/common/url_constants.h", @@ -27,7 +26,12 @@ specific_include_rules = { "!content/public/browser/web_contents_observer.h", ], '.*_[a-z]*test\.cc': [ - "+content/public/test", + # TODO(blundell): Bring this list to zero. + # + # Do not add to the list of temporarily-allowed dependencies below, + # and please do not introduce more #includes of these files. + "!content/public/browser/browser_thread.h", + "!content/public/test", # TODO(joi): Bring this list to zero. # diff --git a/components/autofill/core/browser/autofill_driver.h b/components/autofill/core/browser/autofill_driver.h index 2c1e175..faf7950 100644 --- a/components/autofill/core/browser/autofill_driver.h +++ b/components/autofill/core/browser/autofill_driver.h @@ -9,6 +9,10 @@ #include "components/autofill/core/common/form_data.h" +namespace base { +class SequencedWorkerPool; +} + namespace content { class WebContents; } @@ -36,6 +40,10 @@ class AutofillDriver { // know about WebContents. virtual content::WebContents* GetWebContents() = 0; + // Returns the SequencedWorkerPool on which core Autofill code should run + // tasks that may block. This pool must live at least as long as the driver. + virtual base::SequencedWorkerPool* GetBlockingPool() = 0; + // Returns true iff the renderer is available for communication. virtual bool RendererIsAvailable() = 0; diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index 4b2afb1..5877ab4 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -44,7 +44,6 @@ #include "components/autofill/core/common/password_form_fill_data.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/browser_context.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" @@ -59,7 +58,6 @@ namespace autofill { typedef PersonalDataManager::GUIDPair GUIDPair; using base::TimeTicks; -using content::BrowserThread; using content::RenderViewHost; using WebKit::WebFormElement; @@ -139,8 +137,6 @@ void DeterminePossibleFieldTypesForUpload( const std::vector<CreditCard>& credit_cards, const std::string& app_locale, FormStructure* submitted_form) { - DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); - // For each field in the |submitted_form|, extract the value. Then for each // profile or credit card, identify any stored types that match the value. for (size_t i = 0; i < submitted_form->field_count(); ++i) { @@ -297,7 +293,7 @@ bool AutofillManager::OnFormSubmitted(const FormData& form, // Note that ownership of |submitted_form| is passed to the second task, // using |base::Owned|. FormStructure* raw_submitted_form = submitted_form.get(); - BrowserThread::GetBlockingPool()->PostTaskAndReply( + driver_->GetBlockingPool()->PostTaskAndReply( FROM_HERE, base::Bind(&DeterminePossibleFieldTypesForUpload, copied_profiles, diff --git a/components/autofill/core/browser/test_autofill_driver.cc b/components/autofill/core/browser/test_autofill_driver.cc index 2b20c3d..b380696 100644 --- a/components/autofill/core/browser/test_autofill_driver.cc +++ b/components/autofill/core/browser/test_autofill_driver.cc @@ -4,17 +4,26 @@ #include "components/autofill/core/browser/test_autofill_driver.h" +#include "base/threading/sequenced_worker_pool.h" + namespace autofill { TestAutofillDriver::TestAutofillDriver(content::WebContents* web_contents) - : content::WebContentsObserver(web_contents) {} + : content::WebContentsObserver(web_contents), + blocking_pool_(new base::SequencedWorkerPool(4, "TestAutofillDriver")) {} -TestAutofillDriver::~TestAutofillDriver() {} +TestAutofillDriver::~TestAutofillDriver() { + blocking_pool_->Shutdown(); +} content::WebContents* TestAutofillDriver::GetWebContents() { return web_contents(); } +base::SequencedWorkerPool* TestAutofillDriver::GetBlockingPool() { + return blocking_pool_; +} + bool TestAutofillDriver::RendererIsAvailable() { return true; } diff --git a/components/autofill/core/browser/test_autofill_driver.h b/components/autofill/core/browser/test_autofill_driver.h index dbfe4ef..f9c90d6 100644 --- a/components/autofill/core/browser/test_autofill_driver.h +++ b/components/autofill/core/browser/test_autofill_driver.h @@ -7,13 +7,13 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" #include "components/autofill/core/browser/autofill_driver.h" #include "content/public/browser/web_contents_observer.h" namespace autofill { -// This class is only for easier writing of tests. All pure virtual functions -// have been given empty methods. +// This class is only for easier writing of tests. // TODO(blundell): Eliminate this class being a WebContentsObserver once // autofill shared code no longer needs knowledge of WebContents. class TestAutofillDriver : public AutofillDriver, @@ -24,6 +24,7 @@ class TestAutofillDriver : public AutofillDriver, // AutofillDriver implementation. virtual content::WebContents* GetWebContents() OVERRIDE; + virtual base::SequencedWorkerPool* GetBlockingPool() OVERRIDE; virtual bool RendererIsAvailable() OVERRIDE; virtual void SetRendererActionOnFormDataReception( RendererFormDataAction action) OVERRIDE; @@ -35,6 +36,8 @@ class TestAutofillDriver : public AutofillDriver, virtual void RendererShouldClearPreviewedForm() OVERRIDE; private: + scoped_refptr<base::SequencedWorkerPool> blocking_pool_; + DISALLOW_COPY_AND_ASSIGN(TestAutofillDriver); }; |