OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/safe_browsing/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/debug/leak_annotations.h" | 18 #include "base/debug/leak_annotations.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
22 #include "base/metrics/field_trial.h" | 22 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
24 #include "base/metrics/sparse_histogram.h" | 24 #include "base/metrics/sparse_histogram.h" |
25 #include "base/process/launch.h" | |
26 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
27 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
28 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
29 #include "base/task_runner_util.h" | 28 #include "base/task_runner_util.h" |
30 #include "base/task_scheduler/post_task.h" | 29 #include "base/task_scheduler/post_task.h" |
31 #include "base/task_scheduler/task_traits.h" | 30 #include "base/task_scheduler/task_traits.h" |
32 #include "base/time/time.h" | 31 #include "base/time/time.h" |
33 #include "base/version.h" | 32 #include "base/version.h" |
34 #include "base/win/registry.h" | 33 #include "base/win/registry.h" |
35 #include "chrome/browser/browser_process.h" | 34 #include "chrome/browser/browser_process.h" |
36 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 35 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
37 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/profiles/profile_io_data.h" | 37 #include "chrome/browser/profiles/profile_io_data.h" |
| 38 #include "chrome/browser/safe_browsing/srt_chrome_prompt_impl.h" |
39 #include "chrome/browser/safe_browsing/srt_client_info_win.h" | 39 #include "chrome/browser/safe_browsing/srt_client_info_win.h" |
40 #include "chrome/browser/safe_browsing/srt_global_error_win.h" | 40 #include "chrome/browser/safe_browsing/srt_global_error_win.h" |
41 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
42 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
43 #include "chrome/browser/ui/browser_list_observer.h" | 43 #include "chrome/browser/ui/browser_list_observer.h" |
44 #include "chrome/browser/ui/global_error/global_error_service.h" | 44 #include "chrome/browser/ui/global_error/global_error_service.h" |
45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h" |
47 #include "components/component_updater/pref_names.h" | 48 #include "components/component_updater/pref_names.h" |
48 #include "components/data_use_measurement/core/data_use_user_data.h" | 49 #include "components/data_use_measurement/core/data_use_user_data.h" |
49 #include "components/prefs/pref_service.h" | 50 #include "components/prefs/pref_service.h" |
50 #include "components/variations/net/variations_http_headers.h" | 51 #include "components/variations/net/variations_http_headers.h" |
51 #include "components/version_info/version_info.h" | 52 #include "components/version_info/version_info.h" |
52 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
| 54 #include "mojo/edk/embedder/connection_params.h" |
| 55 #include "mojo/edk/embedder/pending_process_connection.h" |
| 56 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 57 #include "mojo/public/cpp/system/message_pipe.h" |
53 #include "net/base/load_flags.h" | 58 #include "net/base/load_flags.h" |
54 #include "net/http/http_status_code.h" | 59 #include "net/http/http_status_code.h" |
55 #include "net/url_request/url_fetcher.h" | 60 #include "net/url_request/url_fetcher.h" |
56 #include "net/url_request/url_fetcher_delegate.h" | 61 #include "net/url_request/url_fetcher_delegate.h" |
57 #include "net/url_request/url_request_context_getter.h" | 62 #include "net/url_request/url_request_context_getter.h" |
58 | 63 |
59 using content::BrowserThread; | 64 using content::BrowserThread; |
60 | 65 |
61 namespace safe_browsing { | 66 namespace safe_browsing { |
62 | 67 |
63 // TODO(b/647763) Change the registry key to properly handle cases when the user | 68 // TODO(b/647763) Change the registry key to properly handle cases when the user |
64 // runs Google Chrome stable alongside Google Chrome SxS. | 69 // runs Google Chrome stable alongside Google Chrome SxS. |
65 const wchar_t kSoftwareRemovalToolRegistryKey[] = | 70 const wchar_t kSoftwareRemovalToolRegistryKey[] = |
66 L"Software\\Google\\Software Removal Tool"; | 71 L"Software\\Google\\Software Removal Tool"; |
67 | 72 |
68 const wchar_t kCleanerSubKey[] = L"Cleaner"; | 73 const wchar_t kCleanerSubKey[] = L"Cleaner"; |
69 | 74 |
70 const wchar_t kEndTimeValueName[] = L"EndTime"; | 75 const wchar_t kEndTimeValueName[] = L"EndTime"; |
71 const wchar_t kStartTimeValueName[] = L"StartTime"; | 76 const wchar_t kStartTimeValueName[] = L"StartTime"; |
72 | 77 |
| 78 const base::Feature kInBrowserCleanerUIFeature{ |
| 79 "InBrowserCleanerUI", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 80 |
| 81 const char kChromeMojoPipeTokenSwitch[] = "chrome-mojo-pipe-token"; |
| 82 |
73 namespace { | 83 namespace { |
74 | 84 |
75 // Used to send UMA information about missing start and end time registry | 85 // Used to send UMA information about missing start and end time registry |
76 // values for the reporter. Replicated in the histograms.xml file, so the order | 86 // values for the reporter. Replicated in the histograms.xml file, so the order |
77 // MUST NOT CHANGE. | 87 // MUST NOT CHANGE. |
78 enum SwReporterRunningTimeRegistryError { | 88 enum SwReporterRunningTimeRegistryError { |
79 REPORTER_RUNNING_TIME_ERROR_NO_ERROR = 0, | 89 REPORTER_RUNNING_TIME_ERROR_NO_ERROR = 0, |
80 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID = 1, | 90 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID = 1, |
81 REPORTER_RUNNING_TIME_ERROR_MISSING_START_TIME = 2, | 91 REPORTER_RUNNING_TIME_ERROR_MISSING_START_TIME = 2, |
82 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME = 3, | 92 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME = 3, |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 if (error->GetBubbleView()) { | 556 if (error->GetBubbleView()) { |
547 show_bubble = false; | 557 show_bubble = false; |
548 break; | 558 break; |
549 } | 559 } |
550 } | 560 } |
551 } | 561 } |
552 if (show_bubble) | 562 if (show_bubble) |
553 global_error->ShowBubbleView(browser); | 563 global_error->ShowBubbleView(browser); |
554 } | 564 } |
555 | 565 |
556 // This function is called from a worker thread to launch the SwReporter and | 566 // Class responsible for launching the reporter process and waiting for its |
557 // wait for termination to collect its exit code. This task could be | 567 // completion. If feature InBrowserCleanerUI is enabled, this object will also |
558 // interrupted by a shutdown at any time, so it shouldn't depend on anything | 568 // be responsible for starting the ChromePromptImpl object on the IO thread and |
559 // external that could be shut down beforehand. | 569 // controlling its lifetime. |
560 int LaunchAndWaitForExit(const SwReporterInvocation& invocation) { | 570 // |
561 if (g_testing_delegate_) | 571 // Expected lifecycle of a SwReporterProcess: |
562 return g_testing_delegate_->LaunchReporter(invocation); | 572 // - created on the UI thread before the reporter process launch is posted |
| 573 // (method ScheduleNextInvocation); |
| 574 // - deleted on the UI thread once ReporterDone() finishes (the method is |
| 575 // called after the reporter process exits). |
| 576 // |
| 577 // If feature InBrowserCleanerUI feature is enabled, the following tasks will |
| 578 // be posted in sequence to the IO Thread and will retain the SwReporterProcess |
| 579 // object: |
| 580 // - creation of a ChromePromptImpl object right after the reporter process is |
| 581 // launched (that object will be responsible for handling IPC requests from |
| 582 // the reporter process); |
| 583 // - deletion of the ChromePromptImpl object on ReporterDone(). |
| 584 // As a consequence, the SwReporterProcess object can outlive ReporterDone() |
| 585 // and will only be deleted after the ChromePromptImpl object is released on |
| 586 // the IO thread. |
| 587 class SwReporterProcess : public base::RefCountedThreadSafe<SwReporterProcess> { |
| 588 public: |
| 589 explicit SwReporterProcess(const SwReporterInvocation& invocation) |
| 590 : invocation_(invocation) {} |
| 591 |
| 592 // This function is called from a worker thread to launch the SwReporter and |
| 593 // wait for termination to collect its exit code. This task could be |
| 594 // interrupted by a shutdown at any time, so it shouldn't depend on anything |
| 595 // external that could be shut down beforehand. |
| 596 int LaunchAndWaitForExitOnBackgroundThread(); |
| 597 |
| 598 // Schedules to release the instance of ChromePromptImpl on the IO thread. |
| 599 void OnReporterDone(); |
| 600 |
| 601 const SwReporterInvocation& invocation() const { return invocation_; } |
| 602 |
| 603 private: |
| 604 friend class base::RefCountedThreadSafe<SwReporterProcess>; |
| 605 ~SwReporterProcess() = default; |
| 606 |
| 607 // Starts a new IPC service implementing the ChromePrompt interface and |
| 608 // launches a new reporter process that can connect to the IPC. |
| 609 base::Process LaunchConnectedReporterProcess(); |
| 610 |
| 611 // Starts a new instance of ChromePromptImpl to receive requests from the |
| 612 // reporter. Must be run on the IO thread. |
| 613 void CreateChromePromptImpl( |
| 614 chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request); |
| 615 |
| 616 // Releases the instance of ChromePromptImpl. Must be run on the IO thread. |
| 617 void ReleaseChromePromptImpl(); |
| 618 |
| 619 // Launches a new process with the command line in the invocation and |
| 620 // provided launch options. Uses g_testing_delegate_ if not null. |
| 621 base::Process LaunchReporterProcess( |
| 622 const SwReporterInvocation& invocation, |
| 623 const base::LaunchOptions& launch_options); |
| 624 |
| 625 // The invocation for the current reporter process. |
| 626 SwReporterInvocation invocation_; |
| 627 |
| 628 // Implementation of the ChromePrompt service to be used by the current |
| 629 // reporter process. Can only be accessed on the IO thread. |
| 630 std::unique_ptr<ChromePromptImpl> chrome_prompt_impl_; |
| 631 }; |
| 632 |
| 633 int SwReporterProcess::LaunchAndWaitForExitOnBackgroundThread() { |
563 base::Process reporter_process = | 634 base::Process reporter_process = |
564 base::LaunchProcess(invocation.command_line, base::LaunchOptions()); | 635 base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature) |
| 636 ? LaunchConnectedReporterProcess() |
| 637 : LaunchReporterProcess(invocation_, base::LaunchOptions()); |
| 638 |
565 // This exit code is used to identify that a reporter run didn't happen, so | 639 // This exit code is used to identify that a reporter run didn't happen, so |
566 // the result should be ignored and a rerun scheduled for the usual delay. | 640 // the result should be ignored and a rerun scheduled for the usual delay. |
567 int exit_code = kReporterFailureExitCode; | 641 int exit_code = kReporterFailureExitCode; |
568 UMAHistogramReporter uma(invocation.suffix); | 642 UMAHistogramReporter uma(invocation_.suffix); |
569 if (reporter_process.IsValid()) { | 643 if (reporter_process.IsValid()) { |
570 uma.RecordReporterStep(SW_REPORTER_START_EXECUTION); | 644 uma.RecordReporterStep(SW_REPORTER_START_EXECUTION); |
571 bool success = reporter_process.WaitForExit(&exit_code); | 645 bool success = reporter_process.WaitForExit(&exit_code); |
572 DCHECK(success); | 646 DCHECK(success); |
573 } else { | 647 } else { |
574 uma.RecordReporterStep(SW_REPORTER_FAILED_TO_START); | 648 uma.RecordReporterStep(SW_REPORTER_FAILED_TO_START); |
575 } | 649 } |
576 return exit_code; | 650 return exit_code; |
577 } | 651 } |
578 | 652 |
| 653 void SwReporterProcess::OnReporterDone() { |
| 654 if (base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)) { |
| 655 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO) |
| 656 ->PostTask(FROM_HERE, |
| 657 base::Bind(&SwReporterProcess::ReleaseChromePromptImpl, |
| 658 base::RetainedRef(this))); |
| 659 } |
| 660 } |
| 661 |
| 662 base::Process SwReporterProcess::LaunchConnectedReporterProcess() { |
| 663 DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)); |
| 664 |
| 665 mojo::edk::PendingProcessConnection pending_process_connection; |
| 666 std::string mojo_pipe_token; |
| 667 mojo::ScopedMessagePipeHandle mojo_pipe = |
| 668 pending_process_connection.CreateMessagePipe(&mojo_pipe_token); |
| 669 invocation_.command_line.AppendSwitchASCII(kChromeMojoPipeTokenSwitch, |
| 670 mojo_pipe_token); |
| 671 |
| 672 mojo::edk::PlatformChannelPair channel; |
| 673 base::HandlesToInheritVector handles_to_inherit; |
| 674 channel.PrepareToPassClientHandleToChildProcess(&invocation_.command_line, |
| 675 &handles_to_inherit); |
| 676 |
| 677 base::LaunchOptions launch_options; |
| 678 launch_options.handles_to_inherit = &handles_to_inherit; |
| 679 base::Process reporter_process = |
| 680 LaunchReporterProcess(invocation_, launch_options); |
| 681 |
| 682 if (!reporter_process.IsValid()) |
| 683 return reporter_process; |
| 684 |
| 685 pending_process_connection.Connect( |
| 686 reporter_process.Handle(), |
| 687 mojo::edk::ConnectionParams(channel.PassServerHandle())); |
| 688 |
| 689 chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request; |
| 690 chrome_prompt_request.Bind(std::move(mojo_pipe)); |
| 691 |
| 692 // ChromePromptImpl tasks will need to run on the IO thread. There is no |
| 693 // need to synchronize its creation, since the client end will wait for this |
| 694 // initialization to be done before sending requests. |
| 695 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO) |
| 696 ->PostTask(FROM_HERE, |
| 697 base::BindOnce(&SwReporterProcess::CreateChromePromptImpl, |
| 698 base::RetainedRef(this), |
| 699 std::move(chrome_prompt_request))); |
| 700 |
| 701 return reporter_process; |
| 702 } |
| 703 |
| 704 base::Process SwReporterProcess::LaunchReporterProcess( |
| 705 const SwReporterInvocation& invocation, |
| 706 const base::LaunchOptions& launch_options) { |
| 707 return g_testing_delegate_ |
| 708 ? g_testing_delegate_->LaunchReporter(invocation, launch_options) |
| 709 : base::LaunchProcess(invocation.command_line, launch_options); |
| 710 } |
| 711 |
| 712 void SwReporterProcess::CreateChromePromptImpl( |
| 713 chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request) { |
| 714 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 715 DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)); |
| 716 |
| 717 chrome_prompt_impl_ = |
| 718 base::MakeUnique<ChromePromptImpl>(std::move(chrome_prompt_request)); |
| 719 } |
| 720 |
| 721 void SwReporterProcess::ReleaseChromePromptImpl() { |
| 722 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 723 DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)); |
| 724 |
| 725 chrome_prompt_impl_.release(); |
| 726 } |
| 727 |
579 } // namespace | 728 } // namespace |
580 | 729 |
581 void DisplaySRTPromptForTesting(const base::FilePath& download_path) { | 730 void DisplaySRTPromptForTesting(const base::FilePath& download_path) { |
582 DisplaySRTPrompt(download_path); | 731 DisplaySRTPrompt(download_path); |
583 } | 732 } |
584 | 733 |
585 // Class that will attempt to download the SRT, showing the SRT notification | 734 // Class that will attempt to download the SRT, showing the SRT notification |
586 // bubble when the download operation is complete. Instances of SRTFetcher own | 735 // bubble when the download operation is complete. Instances of SRTFetcher own |
587 // themselves, they will self-delete on completion of the network request when | 736 // themselves, they will self-delete on completion of the network request when |
588 // OnURLFetchComplete is called. | 737 // OnURLFetchComplete is called. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 void ScheduleNextInvocation() { | 913 void ScheduleNextInvocation() { |
765 DCHECK(!current_invocations_.empty()); | 914 DCHECK(!current_invocations_.empty()); |
766 auto next_invocation = current_invocations_.front(); | 915 auto next_invocation = current_invocations_.front(); |
767 current_invocations_.pop(); | 916 current_invocations_.pop(); |
768 | 917 |
769 AppendInvocationSpecificSwitches(&next_invocation); | 918 AppendInvocationSpecificSwitches(&next_invocation); |
770 | 919 |
771 base::TaskRunner* task_runner = | 920 base::TaskRunner* task_runner = |
772 g_testing_delegate_ ? g_testing_delegate_->BlockingTaskRunner() | 921 g_testing_delegate_ ? g_testing_delegate_->BlockingTaskRunner() |
773 : blocking_task_runner_.get(); | 922 : blocking_task_runner_.get(); |
774 base::PostTaskAndReplyWithResult( | 923 auto sw_reporter_process = |
775 task_runner, FROM_HERE, | 924 make_scoped_refptr(new SwReporterProcess(next_invocation)); |
776 base::Bind(&LaunchAndWaitForExit, next_invocation), | 925 auto launch_and_wait = |
| 926 base::Bind(&SwReporterProcess::LaunchAndWaitForExitOnBackgroundThread, |
| 927 sw_reporter_process); |
| 928 auto reporter_done = |
777 base::Bind(&ReporterRunner::ReporterDone, base::Unretained(this), Now(), | 929 base::Bind(&ReporterRunner::ReporterDone, base::Unretained(this), Now(), |
778 version_, next_invocation)); | 930 version_, std::move(sw_reporter_process)); |
| 931 base::PostTaskAndReplyWithResult(task_runner, FROM_HERE, |
| 932 std::move(launch_and_wait), |
| 933 std::move(reporter_done)); |
779 } | 934 } |
780 | 935 |
781 // This method is called on the UI thread when an invocation of the reporter | 936 // This method is called on the UI thread when an invocation of the reporter |
782 // has completed. This is run as a task posted from an interruptible worker | 937 // has completed. This is run as a task posted from an interruptible worker |
783 // thread so should be resilient to unexpected shutdown. | 938 // thread so should be resilient to unexpected shutdown. |
784 void ReporterDone(const base::Time& reporter_start_time, | 939 void ReporterDone(const base::Time& reporter_start_time, |
785 const base::Version& version, | 940 const base::Version& version, |
786 const SwReporterInvocation& finished_invocation, | 941 scoped_refptr<SwReporterProcess> sw_reporter_process, |
787 int exit_code) { | 942 int exit_code) { |
788 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 943 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
789 | 944 |
| 945 sw_reporter_process->OnReporterDone(); |
| 946 |
790 base::Time now = Now(); | 947 base::Time now = Now(); |
791 base::TimeDelta reporter_running_time = now - reporter_start_time; | 948 base::TimeDelta reporter_running_time = now - reporter_start_time; |
792 | 949 |
793 // Don't continue the current queue of reporters if one failed to launch. | 950 // Don't continue the current queue of reporters if one failed to launch. |
794 if (exit_code == kReporterFailureExitCode) | 951 if (exit_code == kReporterFailureExitCode) |
795 current_invocations_ = SwReporterQueue(); | 952 current_invocations_ = SwReporterQueue(); |
796 | 953 |
797 // As soon as we're not running this queue, schedule the next overall queue | 954 // As soon as we're not running this queue, schedule the next overall queue |
798 // run after the regular delay. (If there was a failure it's not worth | 955 // run after the regular delay. (If there was a failure it's not worth |
799 // retrying earlier, risking running too often if it always fails, since | 956 // retrying earlier, risking running too often if it always fails, since |
800 // not many users fail here.) | 957 // not many users fail here.) |
801 if (current_invocations_.empty()) { | 958 if (current_invocations_.empty()) { |
802 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 959 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
803 FROM_HERE, | 960 FROM_HERE, |
804 base::Bind(&ReporterRunner::TryToRun, base::Unretained(this)), | 961 base::Bind(&ReporterRunner::TryToRun, base::Unretained(this)), |
805 base::TimeDelta::FromDays(days_between_reporter_runs_)); | 962 base::TimeDelta::FromDays(days_between_reporter_runs_)); |
806 } else { | 963 } else { |
807 ScheduleNextInvocation(); | 964 ScheduleNextInvocation(); |
808 } | 965 } |
809 | 966 |
810 // If the reporter failed to launch, do not process the results. (The exit | 967 // If the reporter failed to launch, do not process the results. (The exit |
811 // code itself doesn't need to be logged in this case because | 968 // code itself doesn't need to be logged in this case because |
812 // SW_REPORTER_FAILED_TO_START is logged in |LaunchAndWaitForExit|.) | 969 // SW_REPORTER_FAILED_TO_START is logged in |
| 970 // |LaunchAndWaitForExitOnBackgroundThread|.) |
813 if (exit_code == kReporterFailureExitCode) | 971 if (exit_code == kReporterFailureExitCode) |
814 return; | 972 return; |
815 | 973 |
| 974 const auto& finished_invocation = sw_reporter_process->invocation(); |
816 UMAHistogramReporter uma(finished_invocation.suffix); | 975 UMAHistogramReporter uma(finished_invocation.suffix); |
817 uma.ReportVersion(version); | 976 uma.ReportVersion(version); |
818 uma.ReportExitCode(exit_code); | 977 uma.ReportExitCode(exit_code); |
819 uma.ReportEngineErrorCode(); | 978 uma.ReportEngineErrorCode(); |
820 uma.ReportFoundUwS(); | 979 uma.ReportFoundUwS(); |
821 | 980 |
822 PrefService* local_state = g_browser_process->local_state(); | 981 PrefService* local_state = g_browser_process->local_state(); |
823 if (local_state) { | 982 if (local_state) { |
824 if (finished_invocation.BehaviourIsSupported( | 983 if (finished_invocation.BehaviourIsSupported( |
825 SwReporterInvocation::BEHAVIOUR_LOG_EXIT_CODE_TO_PREFS)) { | 984 SwReporterInvocation::BEHAVIOUR_LOG_EXIT_CODE_TO_PREFS)) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 // The queue of invocations that are currently running. | 1145 // The queue of invocations that are currently running. |
987 SwReporterQueue current_invocations_; | 1146 SwReporterQueue current_invocations_; |
988 | 1147 |
989 // The invocations to run next time the SwReporter is run. | 1148 // The invocations to run next time the SwReporter is run. |
990 SwReporterQueue pending_invocations_; | 1149 SwReporterQueue pending_invocations_; |
991 | 1150 |
992 base::Version version_; | 1151 base::Version version_; |
993 | 1152 |
994 scoped_refptr<base::TaskRunner> blocking_task_runner_ = | 1153 scoped_refptr<base::TaskRunner> blocking_task_runner_ = |
995 base::CreateTaskRunnerWithTraits( | 1154 base::CreateTaskRunnerWithTraits( |
996 // LaunchAndWaitForExit() creates (MayBlock()) and joins | 1155 // LaunchAndWaitForExitOnBackgroundThread() creates (MayBlock()) and |
997 // (WithBaseSyncPrimitives()) a process. | 1156 // joins (WithBaseSyncPrimitives()) a process. |
998 base::TaskTraits() | 1157 base::TaskTraits() |
999 .WithShutdownBehavior( | 1158 .WithShutdownBehavior( |
1000 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 1159 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
1001 .WithPriority(base::TaskPriority::BACKGROUND) | 1160 .WithPriority(base::TaskPriority::BACKGROUND) |
1002 .MayBlock() | 1161 .MayBlock() |
1003 .WithBaseSyncPrimitives()); | 1162 .WithBaseSyncPrimitives()); |
1004 | 1163 |
1005 // This value is used to identify how long to wait before starting a new run | 1164 // This value is used to identify how long to wait before starting a new run |
1006 // of the reporter queue. It's initialized with the default value and may be | 1165 // of the reporter queue. It's initialized with the default value and may be |
1007 // changed to a different value when a prompt is pending and the reporter | 1166 // changed to a different value when a prompt is pending and the reporter |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), | 1231 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), |
1073 KEY_QUERY_VALUE) == ERROR_SUCCESS && | 1232 KEY_QUERY_VALUE) == ERROR_SUCCESS && |
1074 srt_cleaner_key.GetValueCount() > 0; | 1233 srt_cleaner_key.GetValueCount() > 0; |
1075 } | 1234 } |
1076 | 1235 |
1077 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { | 1236 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { |
1078 g_testing_delegate_ = delegate; | 1237 g_testing_delegate_ = delegate; |
1079 } | 1238 } |
1080 | 1239 |
1081 } // namespace safe_browsing | 1240 } // namespace safe_browsing |
OLD | NEW |