summaryrefslogtreecommitdiffstats
path: root/chrome_elf
diff options
context:
space:
mode:
authorcaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 21:22:21 +0000
committercaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 21:22:21 +0000
commitce05fd0d65d7308400f2eec1fb3e4966cef51c3f (patch)
treec1b52b0f3893a19aaa02b1067ceaa5906e3c9e0d /chrome_elf
parent27198c59523168aad3644a32a3a8d0644696d088 (diff)
downloadchromium_src-ce05fd0d65d7308400f2eec1fb3e4966cef51c3f.zip
chromium_src-ce05fd0d65d7308400f2eec1fb3e4966cef51c3f.tar.gz
chromium_src-ce05fd0d65d7308400f2eec1fb3e4966cef51c3f.tar.bz2
Modify fileAtPath stat to track if the call was redirected by chrome_elf.
TEST=Manual: Start chrome.exe, wait ~60s and check chrome://histograms, the Stability.FileAtPath metric should have run (at least) once, and the resulting value should be 6, assuming the check succeeded. Review URL: https://codereview.chromium.org/169093007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_elf')
-rw-r--r--chrome_elf/chrome_elf.def1
-rw-r--r--chrome_elf/chrome_elf.gyp10
-rw-r--r--chrome_elf/chrome_redirects.def1
-rw-r--r--chrome_elf/chrome_redirects_main.cc14
-rw-r--r--chrome_elf/create_file/chrome_create_file.cc8
-rw-r--r--chrome_elf/create_file/chrome_create_file.h3
6 files changed, 37 insertions, 0 deletions
diff --git a/chrome_elf/chrome_elf.def b/chrome_elf/chrome_elf.def
index ee9808f..026f9c6 100644
--- a/chrome_elf/chrome_elf.def
+++ b/chrome_elf/chrome_elf.def
@@ -6,5 +6,6 @@ LIBRARY "chrome_elf.dll"
EXPORTS
CreateFileW=CreateFileWRedirect
+ GetRedirectCount
IsBlacklistInitialized
SignalChromeElf
diff --git a/chrome_elf/chrome_elf.gyp b/chrome_elf/chrome_elf.gyp
index 00cee29..fa6ed36 100644
--- a/chrome_elf/chrome_elf.gyp
+++ b/chrome_elf/chrome_elf.gyp
@@ -40,6 +40,15 @@
],
},
},
+ 'conditions': [
+ ['component=="shared_library"', {
+ # In component builds, all targets depend on chrome_redirects by
+ # default. Remove it here to avoid a circular dependency.
+ 'dependencies!': [
+ '../chrome_elf/chrome_elf.gyp:chrome_redirects',
+ ],
+ }],
+ ],
},
{
'target_name': 'chrome_elf_unittests_exe',
@@ -168,6 +177,7 @@
],
'sources': [
'chrome_redirects.def',
+ 'chrome_redirects_main.cc',
],
'dependencies': [
'chrome_elf_lib',
diff --git a/chrome_elf/chrome_redirects.def b/chrome_elf/chrome_redirects.def
index 30eb718..1238dc6 100644
--- a/chrome_elf/chrome_redirects.def
+++ b/chrome_elf/chrome_redirects.def
@@ -6,3 +6,4 @@ LIBRARY "chrome_redirects.dll"
EXPORTS
CreateFileW=CreateFileWRedirect
+ GetRedirectCount
diff --git a/chrome_elf/chrome_redirects_main.cc b/chrome_elf/chrome_redirects_main.cc
new file mode 100644
index 0000000..960d07c
--- /dev/null
+++ b/chrome_elf/chrome_redirects_main.cc
@@ -0,0 +1,14 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <windows.h>
+
+#include "chrome_elf/ntdll_cache.h"
+
+BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
+ if (reason == DLL_PROCESS_ATTACH)
+ InitCache();
+
+ return TRUE;
+}
diff --git a/chrome_elf/create_file/chrome_create_file.cc b/chrome_elf/create_file/chrome_create_file.cc
index 6bb2c78..1b8515f 100644
--- a/chrome_elf/create_file/chrome_create_file.cc
+++ b/chrome_elf/create_file/chrome_create_file.cc
@@ -44,6 +44,9 @@ PathIsPrefixFunction g_path_is_prefix_func;
PathFindFileName g_path_find_filename_func;
SHGetFolderPathFunction g_get_folder_func;
+// Record the number of calls we've redirected so far.
+int g_redirect_count = 0;
+
// Populates the g_*_func pointers to functions which will be used in
// ShouldBypass(). Chrome_elf cannot have a load-time dependency on shell32 or
// shlwapi as this would induce a load-time dependency on user32.dll. Instead,
@@ -93,6 +96,7 @@ HANDLE WINAPI CreateFileWRedirect(
DWORD flags_and_attributes,
HANDLE template_file) {
if (ShouldBypass(file_name)) {
+ ++g_redirect_count;
return CreateFileNTDLL(file_name,
desired_access,
share_mode,
@@ -111,6 +115,10 @@ HANDLE WINAPI CreateFileWRedirect(
}
+int GetRedirectCount() {
+ return g_redirect_count;
+}
+
HANDLE CreateFileNTDLL(
LPCWSTR file_name,
DWORD desired_access,
diff --git a/chrome_elf/create_file/chrome_create_file.h b/chrome_elf/create_file/chrome_create_file.h
index dac93af..f9f15c3 100644
--- a/chrome_elf/create_file/chrome_create_file.h
+++ b/chrome_elf/create_file/chrome_create_file.h
@@ -20,6 +20,9 @@ extern "C" HANDLE WINAPI CreateFileWRedirect(
DWORD flags_and_attributes,
HANDLE template_file);
+// Returns the count of CreateFile calls redirected so far.
+extern "C" int GetRedirectCount();
+
// Partial reimplementation of kernel32!CreateFile (very partial: only handles
// reading and writing to files in the User Data directory).
HANDLE CreateFileNTDLL(