| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/domain_reliability/service_factory.h" | 8 #include "chrome/browser/domain_reliability/service_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Note: In an ideal world, instead of appending the command-line switch and | 29 // Note: In an ideal world, instead of appending the command-line switch and |
| 30 // manually setting discard_uploads to false, Domain Reliability would | 30 // manually setting discard_uploads to false, Domain Reliability would |
| 31 // continuously monitor the metrics reporting pref, and the test could just | 31 // continuously monitor the metrics reporting pref, and the test could just |
| 32 // set the pref. | 32 // set the pref. |
| 33 | 33 |
| 34 void SetUpCommandLine(base::CommandLine* command_line) override { | 34 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 35 command_line->AppendSwitch(switches::kEnableDomainReliability); | 35 command_line->AppendSwitch(switches::kEnableDomainReliability); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void SetUpOnMainThread() override { | 38 void SetUpOnMainThread() override { |
| 39 InProcessBrowserTest::SetUpOnMainThread(); | |
| 40 | |
| 41 DomainReliabilityService* service = GetService(); | 39 DomainReliabilityService* service = GetService(); |
| 42 if (service) | 40 if (service) |
| 43 service->SetDiscardUploadsForTesting(false); | 41 service->SetDiscardUploadsForTesting(false); |
| 44 } | 42 } |
| 45 | 43 |
| 46 DomainReliabilityService* GetService() { | 44 DomainReliabilityService* GetService() { |
| 47 return DomainReliabilityServiceFactory::GetForBrowserContext( | 45 return DomainReliabilityServiceFactory::GetForBrowserContext( |
| 48 browser()->profile()); | 46 browser()->profile()); |
| 49 } | 47 } |
| 50 | 48 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 90 |
| 93 service->ForceUploadsForTesting(); | 91 service->ForceUploadsForTesting(); |
| 94 | 92 |
| 95 // At this point, there is an upload pending. If everything goes well, the | 93 // At this point, there is an upload pending. If everything goes well, the |
| 96 // test will finish, destroy the profile, and Domain Reliability will shut | 94 // test will finish, destroy the profile, and Domain Reliability will shut |
| 97 // down properly. If things go awry, it may crash as terminating the pending | 95 // down properly. If things go awry, it may crash as terminating the pending |
| 98 // upload calls into already-destroyed parts of the component. | 96 // upload calls into already-destroyed parts of the component. |
| 99 } | 97 } |
| 100 | 98 |
| 101 } // namespace domain_reliability | 99 } // namespace domain_reliability |
| OLD | NEW |