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

Side by Side Diff: chrome/browser/sync/profile_sync_service_session_unittest.cc

Issue 6901031: Profile shouldn't own Session/TabRestore services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again and hope upload works this time Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_temp_dir.h" 9 #include "base/memory/scoped_temp_dir.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "chrome/browser/sessions/session_service.h" 13 #include "chrome/browser/sessions/session_service.h"
14 #include "chrome/browser/sessions/session_service_factory.h"
14 #include "chrome/browser/sessions/session_service_test_helper.h" 15 #include "chrome/browser/sessions/session_service_test_helper.h"
15 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 16 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
16 #include "chrome/browser/sync/engine/syncapi.h" 17 #include "chrome/browser/sync/engine/syncapi.h"
17 #include "chrome/browser/sync/glue/session_change_processor.h" 18 #include "chrome/browser/sync/glue/session_change_processor.h"
18 #include "chrome/browser/sync/glue/session_data_type_controller.h" 19 #include "chrome/browser/sync/glue/session_data_type_controller.h"
19 #include "chrome/browser/sync/glue/session_model_associator.h" 20 #include "chrome/browser/sync/glue/session_model_associator.h"
20 #include "chrome/browser/sync/glue/sync_backend_host.h" 21 #include "chrome/browser/sync/glue/sync_backend_host.h"
21 #include "chrome/browser/sync/profile_sync_factory_mock.h" 22 #include "chrome/browser/sync/profile_sync_factory_mock.h"
22 #include "chrome/browser/sync/profile_sync_test_util.h" 23 #include "chrome/browser/sync/profile_sync_test_util.h"
23 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 24 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 case NotificationType::FOREIGN_SESSION_UPDATED: 89 case NotificationType::FOREIGN_SESSION_UPDATED:
89 notified_of_update_ = true; 90 notified_of_update_ = true;
90 break; 91 break;
91 default: 92 default:
92 NOTREACHED(); 93 NOTREACHED();
93 break; 94 break;
94 } 95 }
95 } 96 }
96 97
97 virtual void TearDown() { 98 virtual void TearDown() {
98 if (profile()->GetSessionService() == service()) 99 if (SessionServiceFactory::GetForProfileIfExisting(profile()) == service())
99 helper_.ReleaseService(); // we transferred ownership to profile 100 helper_.ReleaseService(); // we transferred ownership to profile
100 else 101 else
101 helper_.set_service(NULL); 102 helper_.set_service(NULL);
102 profile()->set_session_service(NULL); 103 SessionServiceFactory::SetForTestProfile(profile(), NULL);
103 sync_service_.reset(); 104 sync_service_.reset();
104 profile()->ResetRequestContext(); 105 profile()->ResetRequestContext();
105 // Pump messages posted by the sync core thread (which may end up 106 // Pump messages posted by the sync core thread (which may end up
106 // posting on the IO thread). 107 // posting on the IO thread).
107 MessageLoop::current()->RunAllPending(); 108 MessageLoop::current()->RunAllPending();
108 io_thread_.Stop(); 109 io_thread_.Stop();
109 MessageLoop::current()->RunAllPending(); 110 MessageLoop::current()->RunAllPending();
110 BrowserWithTestWindowTest::TearDown(); 111 BrowserWithTestWindowTest::TearDown();
111 } 112 }
112 113
113 bool StartSyncService(Task* task, bool will_fail_association) { 114 bool StartSyncService(Task* task, bool will_fail_association) {
114 if (sync_service_.get()) 115 if (sync_service_.get())
115 return false; 116 return false;
116 sync_service_.reset(new TestProfileSyncService( 117 sync_service_.reset(new TestProfileSyncService(
117 &factory_, profile(), "test user", false, task)); 118 &factory_, profile(), "test user", false, task));
118 profile()->set_session_service(helper_.service()); 119 SessionServiceFactory::SetForTestProfile(profile(), helper_.service());
119 120
120 // Register the session data type. 121 // Register the session data type.
121 model_associator_ = 122 model_associator_ =
122 new SessionModelAssociator(sync_service_.get(), 123 new SessionModelAssociator(sync_service_.get(),
123 true /* setup_for_test */); 124 true /* setup_for_test */);
124 change_processor_ = new SessionChangeProcessor( 125 change_processor_ = new SessionChangeProcessor(
125 sync_service_.get(), model_associator_, 126 sync_service_.get(), model_associator_,
126 true /* setup_for_test */); 127 true /* setup_for_test */);
127 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). 128 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)).
128 WillOnce(Return(ProfileSyncFactory::SyncComponents( 129 WillOnce(Return(ProfileSyncFactory::SyncComponents(
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 ASSERT_FALSE(model_associator_->tab_pool_.full()); 434 ASSERT_FALSE(model_associator_->tab_pool_.full());
434 for (size_t i = 0; i < num_ids; ++i) { 435 for (size_t i = 0; i < num_ids; ++i) {
435 model_associator_->tab_pool_.FreeTabNode(node_ids[i]); 436 model_associator_->tab_pool_.FreeTabNode(node_ids[i]);
436 } 437 }
437 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity()); 438 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity());
438 ASSERT_FALSE(model_associator_->tab_pool_.empty()); 439 ASSERT_FALSE(model_associator_->tab_pool_.empty());
439 ASSERT_TRUE(model_associator_->tab_pool_.full()); 440 ASSERT_TRUE(model_associator_->tab_pool_.full());
440 } 441 }
441 442
442 } // namespace browser_sync 443 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698