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

Side by Side Diff: chrome_frame/test/net/fake_external_tab.cc

Issue 12096114: Extract locking behaviour from ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed merge. Created 7 years, 9 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
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_frame/test/net/fake_external_tab.h" 5 #include "chrome_frame/test/net/fake_external_tab.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <exdisp.h> 9 #include <exdisp.h>
10 #include <Winsock2.h> 10 #include <Winsock2.h>
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 int CFUrlRequestUnittestRunner::PreCreateThreads() { 784 int CFUrlRequestUnittestRunner::PreCreateThreads() {
785 fake_chrome_.reset(new FakeExternalTab()); 785 fake_chrome_.reset(new FakeExternalTab());
786 fake_chrome_->Initialize(); 786 fake_chrome_->Initialize();
787 fake_chrome_->browser_process()->PreCreateThreads(); 787 fake_chrome_->browser_process()->PreCreateThreads();
788 ProcessSingleton::NotificationCallback callback( 788 ProcessSingleton::NotificationCallback callback(
789 base::Bind( 789 base::Bind(
790 &CFUrlRequestUnittestRunner::ProcessSingletonNotificationCallback, 790 &CFUrlRequestUnittestRunner::ProcessSingletonNotificationCallback,
791 base::Unretained(this))); 791 base::Unretained(this)));
792 process_singleton_.reset(new ProcessSingleton(fake_chrome_->user_data(), 792 process_singleton_.reset(new ProcessSingleton(fake_chrome_->user_data(),
793 callback)); 793 callback));
794 process_singleton_->Lock(NULL);
795 return 0; 794 return 0;
796 } 795 }
797 796
798 bool CFUrlRequestUnittestRunner::ProcessSingletonNotificationCallback( 797 bool CFUrlRequestUnittestRunner::ProcessSingletonNotificationCallback(
799 const CommandLine& command_line, const base::FilePath& current_directory) { 798 const CommandLine& command_line, const base::FilePath& current_directory) {
800 std::string channel_id = command_line.GetSwitchValueASCII( 799 std::string channel_id = command_line.GetSwitchValueASCII(
801 switches::kAutomationClientChannelID); 800 switches::kAutomationClientChannelID);
802 EXPECT_FALSE(channel_id.empty()); 801 EXPECT_FALSE(channel_id.empty());
803 802
804 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile( 803 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(
(...skipping 10 matching lines...) Expand all
815 fake_chrome_->InitializePostThreadsCreated(); 814 fake_chrome_->InitializePostThreadsCreated();
816 // Call Create directly instead of NotifyOtherProcessOrCreate as failure is 815 // Call Create directly instead of NotifyOtherProcessOrCreate as failure is
817 // prefered to notifying another process here. 816 // prefered to notifying another process here.
818 if (!process_singleton_->Create()) { 817 if (!process_singleton_->Create()) {
819 LOG(FATAL) << "Failed to start up ProcessSingleton. Is another test " 818 LOG(FATAL) << "Failed to start up ProcessSingleton. Is another test "
820 << "executable or Chrome Frame running?"; 819 << "executable or Chrome Frame running?";
821 if (crash_service_) 820 if (crash_service_)
822 base::KillProcess(crash_service_, 0, false); 821 base::KillProcess(crash_service_, 0, false);
823 ::ExitProcess(1); 822 ::ExitProcess(1);
824 } 823 }
825
826 StartChromeFrameInHostBrowser();
827 } 824 }
828 825
829 bool CFUrlRequestUnittestRunner::MainMessageLoopRun(int* result_code) { 826 bool CFUrlRequestUnittestRunner::MainMessageLoopRun(int* result_code) {
830 DCHECK(MessageLoop::current()); 827 DCHECK(MessageLoop::current());
831 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); 828 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI);
832 829
833 // We need to allow IO on the main thread for these tests. 830 // We need to allow IO on the main thread for these tests.
834 base::ThreadRestrictions::SetIOAllowed(true); 831 base::ThreadRestrictions::SetIOAllowed(true);
835 process_singleton_->Unlock(); 832 StartChromeFrameInHostBrowser();
836 StartInitializationTimeout(); 833 StartInitializationTimeout();
837 return false; 834 return false;
838 } 835 }
839 836
840 void CFUrlRequestUnittestRunner::PostMainMessageLoopRun() { 837 void CFUrlRequestUnittestRunner::PostMainMessageLoopRun() {
841 process_singleton_->Cleanup(); 838 process_singleton_->Cleanup();
842 fake_chrome_->browser_process()->StartTearDown(); 839 fake_chrome_->browser_process()->StartTearDown();
843 840
844 // Must do this separately as the mock profile_manager_ is not the 841 // Must do this separately as the mock profile_manager_ is not the
845 // same member as BrowserProcessImpl::StartTearDown resets. 842 // same member as BrowserProcessImpl::StartTearDown resets.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 content::InitializeSandboxInfo(&sandbox_info); 968 content::InitializeSandboxInfo(&sandbox_info);
972 FakeMainDelegate delegate; 969 FakeMainDelegate delegate;
973 content::ContentMain( 970 content::ContentMain(
974 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), 971 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)),
975 &sandbox_info, 972 &sandbox_info,
976 &delegate); 973 &delegate);
977 974
978 // Note: In debug builds, we ExitProcess during PostDestroyThreads. 975 // Note: In debug builds, we ExitProcess during PostDestroyThreads.
979 return g_test_suite->test_result(); 976 return g_test_suite->test_result();
980 } 977 }
OLDNEW
« chrome/browser/process_singleton_win.cc ('K') | « chrome/chrome_browser.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698