summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 05:59:37 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 05:59:37 +0000
commit6fad26338ed6119903826156f307e20fe6657c31 (patch)
tree5c6baed35fce907a0cea47ed6091c941db8ebfd1 /chrome/browser/sync
parentf75c8f13b967b01babc9454506e9d2ed00519e39 (diff)
downloadchromium_src-6fad26338ed6119903826156f307e20fe6657c31.zip
chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.gz
chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.bz2
Third patch in getting rid of caching MessageLoop pointers and always using ChromeThread instead.
BUG=25354 Review URL: http://codereview.chromium.org/342068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc8
-rw-r--r--chrome/browser/sync/sync_setup_wizard.cc20
-rw-r--r--chrome/browser/sync/sync_setup_wizard_unittest.cc8
3 files changed, 25 insertions, 11 deletions
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 30fea8b..8d2f535 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -11,6 +11,7 @@
#include "base/string_util.h"
#include "base/string16.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/glue/model_associator.h"
@@ -267,7 +268,10 @@ class ProfileSyncServiceTest : public testing::Test {
protected:
enum LoadOption { LOAD_FROM_STORAGE, DELETE_EXISTING_STORAGE };
enum SaveOption { SAVE_TO_STORAGE, DONT_SAVE_TO_STORAGE };
- ProfileSyncServiceTest() : model_(NULL) {
+ ProfileSyncServiceTest()
+ : ui_thread_(ChromeThread::UI, &message_loop_),
+ file_thread_(ChromeThread::FILE, &message_loop_),
+ model_(NULL) {
profile_.reset(new TestingProfile());
profile_->set_has_history_service(true);
}
@@ -464,6 +468,8 @@ class ProfileSyncServiceTest : public testing::Test {
// avoid leaking the ProfileSyncService (the PostTask will retain the callee
// and caller until the task is run).
MessageLoop message_loop_;
+ ChromeThread ui_thread_;
+ ChromeThread file_thread_;
scoped_ptr<ProfileSyncService> service_;
scoped_ptr<TestingProfile> profile_;
diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc
index 35e05f5..2e4664d 100644
--- a/chrome/browser/sync/sync_setup_wizard.cc
+++ b/chrome/browser/sync/sync_setup_wizard.cc
@@ -9,7 +9,7 @@
#include "base/singleton.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_setup_flow.h"
@@ -137,14 +137,16 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service)
: service_(service),
flow_container_(new SyncSetupFlowContainer()) {
- // Register data sources for HTML content we require.
- // g_browser_process and/or io_thread may not exist during testing.
- if (g_browser_process && g_browser_process->io_thread()) {
- // Add our network layer data source for 'cloudy' URLs.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(Singleton<ChromeURLDataManager>().get(),
- &ChromeURLDataManager::AddDataSource,
- new SyncResourcesSource()));
+ // Add our network layer data source for 'cloudy' URLs.
+ SyncResourcesSource* sync_source = new SyncResourcesSource();
+ bool posted = ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(Singleton<ChromeURLDataManager>().get(),
+ &ChromeURLDataManager::AddDataSource,
+ sync_source));
+ if (!posted) {
+ sync_source->AddRef();
+ sync_source->Release(); // Keep Valgrind happy in unit tests.
}
}
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc
index 10f5a7a..2cc16bf 100644
--- a/chrome/browser/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc
@@ -141,7 +141,11 @@ class TestBrowserWindowForWizardTest : public TestBrowserWindow {
class SyncSetupWizardTest : public BrowserWithTestWindowTest {
public:
- SyncSetupWizardTest() : test_window_(NULL), wizard_(NULL) { }
+ SyncSetupWizardTest()
+ : ui_thread_(ChromeThread::UI, MessageLoop::current()),
+ file_thread_(ChromeThread::FILE, MessageLoop::current()),
+ test_window_(NULL),
+ wizard_(NULL) { }
virtual ~SyncSetupWizardTest() { }
virtual void SetUp() {
set_profile(new TestingProfileWithSyncService());
@@ -164,6 +168,8 @@ class SyncSetupWizardTest : public BrowserWithTestWindowTest {
wizard_.reset();
}
+ ChromeThread ui_thread_;
+ ChromeThread file_thread_;
TestBrowserWindowForWizardTest* test_window_;
scoped_ptr<SyncSetupWizard> wizard_;
ProfileSyncServiceForWizardTest* service_;