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

Unified Diff: ceee/ie/plugin/bho/cookie_accountant.h

Issue 5290011: Add a lock to the cookie accountant to prevent race conditions in patching... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | ceee/ie/plugin/bho/cookie_accountant.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ceee/ie/plugin/bho/cookie_accountant.h
===================================================================
--- ceee/ie/plugin/bho/cookie_accountant.h (revision 67716)
+++ ceee/ie/plugin/bho/cookie_accountant.h (working copy)
@@ -13,6 +13,7 @@
#include <string>
#include "app/win/iat_patch_function.h"
+#include "base/lock.h"
#include "base/singleton.h"
#include "base/time.h"
#include "ceee/ie/plugin/bho/cookie_events_funnel.h"
@@ -52,7 +53,11 @@
// Since this class has one instance per window, not per tab, we cannot
// queue the events sent to the broker. They don't need to be sent to the BHO
// because they don't need tab_id anyway.
- CookieAccountant() : cookie_events_funnel_(new BrokerRpcClient) {}
+ CookieAccountant()
+ : cookie_events_funnel_(new BrokerRpcClient),
+ patching_wininet_functions_(false) {
+ }
+
virtual ~CookieAccountant();
// Records the modification or creation of a cookie. Fires off a
@@ -70,6 +75,15 @@
app::win::IATPatchFunction internet_set_cookie_ex_a_patch_;
app::win::IATPatchFunction internet_set_cookie_ex_w_patch_;
+ // Used to allow exactly one thread to attempt to apply function patches.
+ // We use this boolean instead of a simple lock so that threads that lose
+ // the race will return immediately instead of blocking on the lock.
+ // Protected by CookieAccountant::lock_.
+ bool patching_wininet_functions_;
+
+ // A lock that protects access to the function patches.
+ Lock lock_;
+
// Cached singleton instance. Useful for unit testing.
static CookieAccountant* singleton_instance_;
« no previous file with comments | « no previous file | ceee/ie/plugin/bho/cookie_accountant.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698