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

Unified Diff: chrome/common/chrome_paths.cc

Issue 7087014: Support automatic javascript test registry in gtest when creating WebUI tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/chrome_paths.cc
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 1b3061f4cd69476453930a79e2b8ed61db1c2ab9..868ea9efd786d57ed280358ad13a35972637a868 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/memory/singleton.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/sys_info.h"
@@ -18,6 +19,12 @@
#include "base/mac/mac_util.h"
#endif
+namespace chrome {
+
+bool PathProvider(int key, FilePath* result);
+
+} // namespace chrome
+
namespace {
// File name of the internal Flash plugin on different platforms.
@@ -51,6 +58,28 @@ const FilePath::CharType kInternalNaClPluginFileName[] =
FILE_PATH_LITERAL("libppGoogleNaClPluginChrome.so");
#endif
+// web_ui_browsertest needs this service at linker initialization time so we
+// provide ability to register and unregister base on Singleton
+// construction/destruction.
+class RegistryHelper {
+ public:
+ RegistryHelper() {
+ PathService::RegisterProvider(&chrome::PathProvider,
+ chrome::PATH_START, chrome::PATH_END);
+ }
+
+ ~RegistryHelper() {
+ PathService::UnregisterProvider(&chrome::PathProvider);
+ }
+
+ static RegistryHelper* GetInstance() {
+ return Singleton<RegistryHelper>::get();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RegistryHelper);
+};
+
} // namespace
namespace chrome {
@@ -323,7 +352,7 @@ bool PathProvider(int key, FilePath* result) {
// This cannot be done as a static initializer sadly since Visual Studio will
// eliminate this object file if there is no direct entry point into it.
void RegisterPathProvider() {
- PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
+ RegistryHelper::GetInstance();
}
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698