Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/sync/test/integration/sessions_helper.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/test/integration/sessions_helper.h" 5 #include "chrome/browser/sync/test/integration/sessions_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/test/test_timeouts.h" 15 #include "base/test/test_timeouts.h"
16 #include "base/thread_task_runner_handle.h"
14 #include "base/time/time.h" 17 #include "base/time/time.h"
15 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/sync/open_tabs_ui_delegate.h" 19 #include "chrome/browser/sync/open_tabs_ui_delegate.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
18 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
19 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" 22 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h"
20 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" 23 #include "chrome/browser/sync/sessions/sessions_sync_manager.h"
21 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke r.h" 24 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke r.h"
22 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 25 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
23 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 26 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 chrome::ShowSingletonTab(browser, *it); 126 chrome::ShowSingletonTab(browser, *it);
124 } 127 }
125 return WaitForTabsToLoad(index, urls); 128 return WaitForTabsToLoad(index, urls);
126 } 129 }
127 130
128 namespace { 131 namespace {
129 132
130 class TabEventHandler : public browser_sync::LocalSessionEventHandler { 133 class TabEventHandler : public browser_sync::LocalSessionEventHandler {
131 public: 134 public:
132 TabEventHandler() : weak_factory_(this) { 135 TabEventHandler() : weak_factory_(this) {
133 base::MessageLoop::current()->PostDelayedTask( 136 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
134 FROM_HERE, 137 FROM_HERE,
135 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()), 138 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()),
136 TestTimeouts::action_max_timeout()); 139 TestTimeouts::action_max_timeout());
137 } 140 }
138 141
139 void OnLocalTabModified( 142 void OnLocalTabModified(
140 browser_sync::SyncedTabDelegate* modified_tab) override { 143 browser_sync::SyncedTabDelegate* modified_tab) override {
141 // Unwind to ensure SessionsSyncManager has processed the event. 144 // Unwind to ensure SessionsSyncManager has processed the event.
142 base::MessageLoop::current()->PostTask( 145 base::ThreadTaskRunnerHandle::Get()->PostTask(
143 FROM_HERE, 146 FROM_HERE,
144 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); 147 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()));
145 } 148 }
146 149
147 void OnFaviconPageUrlsUpdated( 150 void OnFaviconPageUrlsUpdated(
148 const std::set<GURL>& updated_page_urls) override { 151 const std::set<GURL>& updated_page_urls) override {
149 // Unwind to ensure SessionsSyncManager has processed the event. 152 // Unwind to ensure SessionsSyncManager has processed the event.
150 base::MessageLoop::current()->PostTask( 153 base::ThreadTaskRunnerHandle::Get()->PostTask(
151 FROM_HERE, 154 FROM_HERE,
152 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); 155 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()));
153 } 156 }
154 157
155 private: 158 private:
156 void QuitLoop() { 159 void QuitLoop() {
157 base::MessageLoop::current()->Quit(); 160 base::MessageLoop::current()->Quit();
158 } 161 }
159 162
160 base::WeakPtrFactory<TabEventHandler> weak_factory_; 163 base::WeakPtrFactory<TabEventHandler> weak_factory_;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return !checker.TimedOut(); 406 return !checker.TimedOut();
404 } 407 }
405 408
406 void DeleteForeignSession(int index, std::string session_tag) { 409 void DeleteForeignSession(int index, std::string session_tag) {
407 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 410 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
408 test()->GetProfile(index))-> 411 test()->GetProfile(index))->
409 GetOpenTabsUIDelegate()->DeleteForeignSession(session_tag); 412 GetOpenTabsUIDelegate()->DeleteForeignSession(session_tag);
410 } 413 }
411 414
412 } // namespace sessions_helper 415 } // namespace sessions_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698