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

Side by Side Diff: chrome/app/metro_driver_win.cc

Issue 10497010: Revert 127714 - Load the metro driver dll at startup (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/metro_driver_win.h ('k') | chrome/chrome_exe.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "metro_driver_win.h"
6
7 namespace {
8 // The windows 8 metro driver dll name and entry point.
9 const char kMetroDriverDll[] = "metro_driver.dll";
10 // This environment variable controls the loading of the metro driver DLL.
11 const char* kMetroModeEnvVar = "CHROME_METRO_DLL";
12
13 typedef int (*InitMetro)(LPTHREAD_START_ROUTINE thread_proc, void* context);
14
15 struct Context {
16 MetroDriver::MainFn fn;
17 HINSTANCE instance;
18 };
19
20 DWORD WINAPI MainThread(void* param) {
21 Context* context = reinterpret_cast<Context*>(param);
22 int rv = context->fn(context->instance);
23 delete context;
24 return rv;
25 }
26
27 } // namespace
28
29 MetroDriver::MetroDriver() : init_metro_fn_(NULL) {
30 if (0 != ::GetEnvironmentVariableA(kMetroModeEnvVar, NULL, 0))
31 return;
32 // We haven't tried to load the metro driver, this probably means we are the
33 // browser. Find it or not we set the environment variable because we don't
34 // want to keep trying in the child processes.
35 HMODULE metro_dll = ::LoadLibraryA(kMetroDriverDll);
36 ::SetEnvironmentVariableA(kMetroModeEnvVar, metro_dll ? "1" : "0");
37 if (!metro_dll)
38 return;
39 init_metro_fn_ =
40 ::GetProcAddress(::GetModuleHandleA(kMetroDriverDll), "InitMetro");
41 }
42
43 int MetroDriver::RunInMetro(HINSTANCE instance, MainFn main_fn) {
44 Context* context = new Context;
45 context->fn = main_fn;
46 context->instance = instance;
47
48 return reinterpret_cast<InitMetro>(init_metro_fn_)(&MainThread, context);
49 }
OLDNEW
« no previous file with comments | « chrome/app/metro_driver_win.h ('k') | chrome/chrome_exe.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698