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 "chrome/renderer/chrome_render_process_observer.h" | 5 #include "chrome/renderer/chrome_render_process_observer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/allocator/allocator_extension.h" | 10 #include "base/allocator/allocator_extension.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "crypto/nss_util.h" | 36 #include "crypto/nss_util.h" |
37 #include "net/base/net_errors.h" | 37 #include "net/base/net_errors.h" |
38 #include "net/base/net_module.h" | 38 #include "net/base/net_module.h" |
39 #include "third_party/WebKit/public/web/WebCache.h" | 39 #include "third_party/WebKit/public/web/WebCache.h" |
40 #include "third_party/WebKit/public/web/WebDocument.h" | 40 #include "third_party/WebKit/public/web/WebDocument.h" |
41 #include "third_party/WebKit/public/web/WebFrame.h" | 41 #include "third_party/WebKit/public/web/WebFrame.h" |
42 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 42 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
43 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 43 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
44 #include "third_party/WebKit/public/web/WebView.h" | 44 #include "third_party/WebKit/public/web/WebView.h" |
45 | 45 |
46 #if defined(OS_WIN) | |
47 #include "base/win/iat_patch_function.h" | |
48 #endif | |
49 | |
50 #if defined(ENABLE_EXTENSIONS) | 46 #if defined(ENABLE_EXTENSIONS) |
51 #include "chrome/renderer/extensions/extension_localization_peer.h" | 47 #include "chrome/renderer/extensions/extension_localization_peer.h" |
52 #endif | 48 #endif |
53 | 49 |
54 using blink::WebCache; | 50 using blink::WebCache; |
55 using blink::WebRuntimeFeatures; | 51 using blink::WebRuntimeFeatures; |
56 using blink::WebSecurityPolicy; | 52 using blink::WebSecurityPolicy; |
57 using blink::WebString; | 53 using blink::WebString; |
58 using content::RenderThread; | 54 using content::RenderThread; |
59 | 55 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 WebCache::UsageStats stats; | 101 WebCache::UsageStats stats; |
106 WebCache::getUsageStats(&stats); | 102 WebCache::getUsageStats(&stats); |
107 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); | 103 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); |
108 } | 104 } |
109 | 105 |
110 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; | 106 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; |
111 | 107 |
112 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); | 108 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); |
113 }; | 109 }; |
114 | 110 |
115 #if defined(OS_WIN) | |
116 static base::win::IATPatchFunction g_iat_patch_createdca; | |
117 HDC WINAPI CreateDCAPatch(LPCSTR driver_name, | |
118 LPCSTR device_name, | |
119 LPCSTR output, | |
120 const void* init_data) { | |
121 DCHECK(std::string("DISPLAY") == std::string(driver_name)); | |
122 DCHECK(!device_name); | |
123 DCHECK(!output); | |
124 DCHECK(!init_data); | |
125 | |
126 // CreateDC fails behind the sandbox, but not CreateCompatibleDC. | |
127 return CreateCompatibleDC(NULL); | |
128 } | |
129 | |
130 static base::win::IATPatchFunction g_iat_patch_get_font_data; | |
131 DWORD WINAPI GetFontDataPatch(HDC hdc, | |
132 DWORD table, | |
133 DWORD offset, | |
134 LPVOID buffer, | |
135 DWORD length) { | |
136 int rv = GetFontData(hdc, table, offset, buffer, length); | |
137 if (rv == GDI_ERROR && hdc) { | |
138 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); | |
139 | |
140 LOGFONT logfont; | |
141 if (GetObject(font, sizeof(LOGFONT), &logfont)) { | |
142 std::vector<char> font_data; | |
143 RenderThread::Get()->PreCacheFont(logfont); | |
144 rv = GetFontData(hdc, table, offset, buffer, length); | |
145 RenderThread::Get()->ReleaseCachedFonts(); | |
146 } | |
147 } | |
148 return rv; | |
149 } | |
150 #endif // OS_WIN | |
151 | |
152 static const int kWaitForWorkersStatsTimeoutMS = 20; | 111 static const int kWaitForWorkersStatsTimeoutMS = 20; |
153 | 112 |
154 class HeapStatisticsCollector { | 113 class HeapStatisticsCollector { |
155 public: | 114 public: |
156 HeapStatisticsCollector() : round_id_(0) {} | 115 HeapStatisticsCollector() : round_id_(0) {} |
157 | 116 |
158 void InitiateCollection(); | 117 void InitiateCollection(); |
159 static HeapStatisticsCollector* Instance(); | 118 static HeapStatisticsCollector* Instance(); |
160 | 119 |
161 private: | 120 private: |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); | 232 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); |
274 } | 233 } |
275 | 234 |
276 RenderThread* thread = RenderThread::Get(); | 235 RenderThread* thread = RenderThread::Get(); |
277 resource_delegate_.reset(new RendererResourceDelegate()); | 236 resource_delegate_.reset(new RendererResourceDelegate()); |
278 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); | 237 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); |
279 | 238 |
280 // Configure modules that need access to resources. | 239 // Configure modules that need access to resources. |
281 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 240 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
282 | 241 |
283 #if defined(OS_WIN) | |
284 // TODO(scottmg): http://crbug.com/448473. This code should be removed once | |
285 // PDF is always OOP and/or PDF is made to use Skia instead of GDI directly. | |
286 if (!command_line.HasSwitch(switches::kEnableOutOfProcessPdf)) { | |
287 // Need to patch a few functions for font loading to work correctly. | |
288 base::FilePath pdf; | |
289 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) && | |
290 base::PathExists(pdf)) { | |
291 g_iat_patch_createdca.Patch(pdf.value().c_str(), "gdi32.dll", "CreateDCA", | |
292 CreateDCAPatch); | |
293 g_iat_patch_get_font_data.Patch(pdf.value().c_str(), "gdi32.dll", | |
294 "GetFontData", GetFontDataPatch); | |
295 } | |
296 } | |
297 #endif | |
298 | |
299 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) | 242 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS) |
300 // On platforms where we use system NSS shared libraries, | 243 // On platforms where we use system NSS shared libraries, |
301 // initialize NSS now because it won't be able to load the .so's | 244 // initialize NSS now because it won't be able to load the .so's |
302 // after we engage the sandbox. | 245 // after we engage the sandbox. |
303 if (!command_line.HasSwitch(switches::kSingleProcess)) | 246 if (!command_line.HasSwitch(switches::kSingleProcess)) |
304 crypto::InitNSSSafely(); | 247 crypto::InitNSSSafely(); |
305 #elif defined(OS_WIN) | 248 #elif defined(OS_WIN) |
306 // crypt32.dll is used to decode X509 certificates for Chromoting. | 249 // crypt32.dll is used to decode X509 certificates for Chromoting. |
307 // Only load this library when the feature is enabled. | 250 // Only load this library when the feature is enabled. |
308 base::LoadNativeLibrary(base::FilePath(L"crypt32.dll"), NULL); | 251 base::LoadNativeLibrary(base::FilePath(L"crypt32.dll"), NULL); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 ChromeRenderProcessObserver::content_setting_rules() const { | 334 ChromeRenderProcessObserver::content_setting_rules() const { |
392 return &content_setting_rules_; | 335 return &content_setting_rules_; |
393 } | 336 } |
394 | 337 |
395 void ChromeRenderProcessObserver::OnFieldTrialGroupFinalized( | 338 void ChromeRenderProcessObserver::OnFieldTrialGroupFinalized( |
396 const std::string& trial_name, | 339 const std::string& trial_name, |
397 const std::string& group_name) { | 340 const std::string& group_name) { |
398 content::RenderThread::Get()->Send( | 341 content::RenderThread::Get()->Send( |
399 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); | 342 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); |
400 } | 343 } |
OLD | NEW |