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

Side by Side Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 1325843002: Added directwrite warmup for PPAPI processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_win32k_enable_policy
Patch Set: Made win32k lockdown check a lazy instance. Created 5 years, 3 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
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 "content/ppapi_plugin/ppapi_thread.h" 5 #include "content/ppapi_plugin/ppapi_thread.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/cpu.h" 10 #include "base/cpu.h"
11 #include "base/debug/crash_logging.h" 11 #include "base/debug/crash_logging.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/lazy_instance.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/discardable_memory_allocator.h" 15 #include "base/memory/discardable_memory_allocator.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
17 #include "base/rand_util.h" 18 #include "base/rand_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/threading/platform_thread.h" 21 #include "base/threading/platform_thread.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); 92 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0);
92 } else { 93 } else {
93 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED); 94 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED);
94 } 95 }
95 } 96 }
96 } 97 }
97 98
98 #endif 99 #endif
99 100
101 typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyType;
102
103 // Get win32k lockdown policy using a lazy instance so it's only initialized
palmer 2015/09/15 21:43:43 This is copied and pasted from another CL, right?
forshaw 2015/09/15 21:59:32 I'd love to. Initially I had it in base but wfh@ r
104 // once and is thread-safe.
105 class LazyIsWin32kLockdownEnabled {
106 public:
107 LazyIsWin32kLockdownEnabled() : value_(IsWin32kLockdownEnabled()) {}
108
109 ~LazyIsWin32kLockdownEnabled() {}
110
111 bool value() { return value_; }
112
113 private:
114 static bool IsWin32kLockdownEnabled() {
115 GetProcessMitigationPolicyType get_process_mitigation_policy_func =
116 reinterpret_cast<GetProcessMitigationPolicyType>(GetProcAddress(
117 GetModuleHandle(L"kernel32.dll"), "GetProcessMitigationPolicy"));
118
119 if (!get_process_mitigation_policy_func)
120 return false;
121
122 PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {0};
123 if (get_process_mitigation_policy_func(GetCurrentProcess(),
124 ProcessSystemCallDisablePolicy,
125 &policy, sizeof(policy)))
126 return policy.DisallowWin32kSystemCalls != 0;
127
128 return false;
129 }
130
131 const bool value_;
132
133 DISALLOW_COPY_AND_ASSIGN(LazyIsWin32kLockdownEnabled);
134 };
135
100 namespace content { 136 namespace content {
101 137
138 bool IsWin32kLockdownEnabled() {
139 static base::LazyInstance<LazyIsWin32kLockdownEnabled> win32k_lockdown =
140 LAZY_INSTANCE_INITIALIZER;
141 return win32k_lockdown.Get().value();
142 }
143
102 typedef int32_t (*InitializeBrokerFunc) 144 typedef int32_t (*InitializeBrokerFunc)
103 (PP_ConnectInstance_Func* connect_instance_func); 145 (PP_ConnectInstance_Func* connect_instance_func);
104 146
105 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker) 147 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker)
106 : is_broker_(is_broker), 148 : is_broker_(is_broker),
107 plugin_globals_(GetIOTaskRunner()), 149 plugin_globals_(GetIOTaskRunner()),
108 connect_instance_func_(NULL), 150 connect_instance_func_(NULL),
109 local_pp_module_(base::RandInt(0, std::numeric_limits<PP_Module>::max())), 151 local_pp_module_(base::RandInt(0, std::numeric_limits<PP_Module>::max())),
110 next_plugin_dispatcher_id_(1) { 152 next_plugin_dispatcher_id_(1) {
111 plugin_globals_.SetPluginProxyDelegate(this); 153 plugin_globals_.SetPluginProxyDelegate(this);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 GetHistogramName(is_broker_, "LoadTime", path), 644 GetHistogramName(is_broker_, "LoadTime", path),
603 base::TimeDelta::FromMilliseconds(1), 645 base::TimeDelta::FromMilliseconds(1),
604 base::TimeDelta::FromSeconds(10), 646 base::TimeDelta::FromSeconds(10),
605 50, 647 50,
606 base::HistogramBase::kUmaTargetedHistogramFlag); 648 base::HistogramBase::kUmaTargetedHistogramFlag);
607 649
608 histogram->AddTime(load_time); 650 histogram->AddTime(load_time);
609 } 651 }
610 652
611 } // namespace content 653 } // namespace content
OLDNEW
« content/browser/ppapi_plugin_process_host.cc ('K') | « content/ppapi_plugin/ppapi_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698