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

Side by Side Diff: chrome_frame/module_utils.h

Issue 1994007: Change to a simpler upgrade scheme for Chrome Frame whereby we register a win... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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_frame/chrome_tab.cc ('k') | chrome_frame/module_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_FRAME_MODULE_UTILS_H_ 5 #ifndef CHROME_FRAME_MODULE_UTILS_H_
6 #define CHROME_FRAME_MODULE_UTILS_H_ 6 #define CHROME_FRAME_MODULE_UTILS_H_
7 7
8 #include <ObjBase.h> 8 #include <ObjBase.h>
9 #include <windows.h> 9 #include <windows.h>
10 10
11 #include <map>
12
13 // A helper class that will find the named loaded module in the current
14 // process with the lowest version, increment its ref count and return
15 // a pointer to its DllGetClassObject() function if it exports one. If
16 // the oldest named module is the current module, then this class does nothing
17 // (does not muck with module ref count) and calls to
18 // get_dll_get_class_object_ptr() will return NULL.
19 class DllRedirector { 11 class DllRedirector {
20 public: 12 public:
21 typedef std::map<std::wstring, HMODULE> PathToHModuleMap; 13 // Attempts to register a window class under a well known name and appends to
14 // its extra data a handle to the current module. Will fail if the window
15 // class is already registered. This is intended to be called from DllMain
16 // under PROCESS_ATTACH.
17 static bool DllRedirector::RegisterAsFirstCFModule();
22 18
23 DllRedirector(); 19 // Unregisters the well known window class if we registered it earlier.
24 ~DllRedirector(); 20 // This is intended to be called from DllMain under PROCESS_DETACH.
21 static void DllRedirector::UnregisterAsFirstCFModule();
25 22
26 // Must call this before calling get_dll_get_class_object_ptr(). On first call 23 // Helper function that extracts the HMODULE parameter from our well known
27 // this performs the work of scanning the loaded modules for an old version 24 // window class.
28 // to delegate to. Not thread safe. 25 static HMODULE GetFirstCFModule();
29 void EnsureInitialized(const wchar_t* module_name, REFCLSID clsid);
30 26
31 LPFNGETCLASSOBJECT get_dll_get_class_object_ptr() const;
32
33 private:
34
35 // Returns the pointer to the named loaded module's DllGetClassObject export
36 // or NULL if either the pointer could not be found or if the pointer would
37 // point into the current module.
38 // Sets module_handle_ and increments the modules reference count.
39 //
40 // For sanity's sake, the module must return a non-null class factory for
41 // the given class id.
42 LPFNGETCLASSOBJECT GetDllGetClassObjectFromModuleName(
43 const wchar_t* module_name, REFCLSID clsid);
44
45 // Returns a handle in |module_handle| to the loaded module called
46 // |module_name| in the current process. If there are multiple modules with
47 // the same name, it returns the module with the oldest version number in its
48 // VERSIONINFO block. The version string is expected to be of a form that
49 // base::Version can parse.
50 //
51 // For sanity's sake, when there are multiple instances of the module,
52 // |product_short_name|, if non-NULL, must match the module's
53 // ProductShortName value
54 //
55 // Returns true if a named module with the given ProductShortName can be
56 // found, returns false otherwise. Can return the current module handle.
57 bool GetOldestNamedModuleHandle(const std::wstring& module_name,
58 REFCLSID clsid,
59 HMODULE* module_handle);
60
61 // Given a PathToBaseAddressMap, iterates over the module images whose paths
62 // are the keys and returns the handle to the module with the lowest
63 // version number in its VERSIONINFO block whose DllGetClassObject returns a
64 // class factory for the given CLSID.
65 HMODULE GetHandleOfOldestModule(const PathToHModuleMap& map, REFCLSID clsid);
66
67 private:
68 // Helper function to return the DllGetClassObject function pointer from 27 // Helper function to return the DllGetClassObject function pointer from
69 // the given module. On success, the return value is non-null and module 28 // the given module. On success, the return value is non-null and module
70 // will have had its reference count incremented. 29 // will have had its reference count incremented.
71 LPFNGETCLASSOBJECT GetDllGetClassObjectPtr(HMODULE module); 30 static LPFNGETCLASSOBJECT GetDllGetClassObjectPtr(HMODULE module);
72 31
73 HMODULE module_handle_; 32 private:
74 LPFNGETCLASSOBJECT dcgo_ptr_; 33 // Use this to keep track of whether or not we have registered the window
75 bool initialized_; 34 // class in this module.
35 static ATOM atom_;
76 36
77 friend class ModuleUtilsTest; 37 friend class ModuleUtilsTest;
78 }; 38 };
79 39
80 #endif // CHROME_FRAME_MODULE_UTILS_H_ 40 #endif // CHROME_FRAME_MODULE_UTILS_H_
OLDNEW
« no previous file with comments | « chrome_frame/chrome_tab.cc ('k') | chrome_frame/module_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698