OLD | NEW |
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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/profiler.h" | 13 #include "base/debug/profiler.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/hash.h" | |
16 #include "base/logging.h" | 15 #include "base/logging.h" |
17 #include "base/macros.h" | 16 #include "base/macros.h" |
18 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
19 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
20 #include "base/metrics/sparse_histogram.h" | 19 #include "base/metrics/sparse_histogram.h" |
21 #include "base/path_service.h" | 20 #include "base/path_service.h" |
22 #include "base/process/launch.h" | 21 #include "base/process/launch.h" |
23 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
25 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 TRACE_EVENT1("startup", "StartProcessWithAccess", "type", type_str); | 673 TRACE_EVENT1("startup", "StartProcessWithAccess", "type", type_str); |
675 | 674 |
676 // Propagate the --allow-no-job flag if present. | 675 // Propagate the --allow-no-job flag if present. |
677 if (browser_command_line.HasSwitch(switches::kAllowNoSandboxJob) && | 676 if (browser_command_line.HasSwitch(switches::kAllowNoSandboxJob) && |
678 !cmd_line->HasSwitch(switches::kAllowNoSandboxJob)) { | 677 !cmd_line->HasSwitch(switches::kAllowNoSandboxJob)) { |
679 cmd_line->AppendSwitch(switches::kAllowNoSandboxJob); | 678 cmd_line->AppendSwitch(switches::kAllowNoSandboxJob); |
680 } | 679 } |
681 | 680 |
682 ProcessDebugFlags(cmd_line); | 681 ProcessDebugFlags(cmd_line); |
683 | 682 |
684 // Prefetch hints on windows: | |
685 // Using a different prefetch profile per process type will allow Windows | |
686 // to create separate pretetch settings for browser, renderer etc. | |
687 cmd_line->AppendArg(base::StringPrintf("/prefetch:%d", base::Hash(type_str))); | |
688 | |
689 if ((!delegate->ShouldSandbox()) || | 683 if ((!delegate->ShouldSandbox()) || |
690 browser_command_line.HasSwitch(switches::kNoSandbox) || | 684 browser_command_line.HasSwitch(switches::kNoSandbox) || |
691 cmd_line->HasSwitch(switches::kNoSandbox)) { | 685 cmd_line->HasSwitch(switches::kNoSandbox)) { |
692 base::Process process = | 686 base::Process process = |
693 base::LaunchProcess(*cmd_line, base::LaunchOptions()); | 687 base::LaunchProcess(*cmd_line, base::LaunchOptions()); |
694 // TODO(rvargas) crbug.com/417532: Don't share a raw handle. | 688 // TODO(rvargas) crbug.com/417532: Don't share a raw handle. |
695 g_broker_services->AddTargetPeer(process.Handle()); | 689 g_broker_services->AddTargetPeer(process.Handle()); |
696 return process.Pass(); | 690 return process.Pass(); |
697 } | 691 } |
698 | 692 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 853 } |
860 | 854 |
861 return false; | 855 return false; |
862 } | 856 } |
863 | 857 |
864 bool BrokerAddTargetPeer(HANDLE peer_process) { | 858 bool BrokerAddTargetPeer(HANDLE peer_process) { |
865 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 859 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
866 } | 860 } |
867 | 861 |
868 } // namespace content | 862 } // namespace content |
OLD | NEW |