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

Unified Diff: content/public/test/test_utils.h

Issue 128993004: Fix subtle bug with the in-process utility thread usage in unit tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 6 years, 11 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: content/public/test/test_utils.h
===================================================================
--- content/public/test/test_utils.h (revision 243741)
+++ content/public/test/test_utils.h (working copy)
@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
+#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
@@ -184,6 +185,34 @@
DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver);
};
+// Unit tests can use code which runs in the utility process by having it run on
+// an in-process utility thread. This eliminates having two code paths in
+// production code to deal with unit tests, and also helps with the binary
+// separation on Windows since chrome.dll doesn't need to call into Blink code
+// for some utility code to handle the single process case.
+// Include this class as a member variable in your test harness if you take
+// advantage of this functionality to ensure that the in-process utility thread
+// is torn down correctly. See http://crbug.com/316919 for more information.
+// Note: this class should be declared after the TestBrowserThreadBundle and
+// ShadowingAtExitManager (if it exists) as it will need to be run before they
+// are torn down.
+class InProcessUtilityThreadHelper : public BrowserChildProcessObserver {
+ public:
+ InProcessUtilityThreadHelper();
+ virtual ~InProcessUtilityThreadHelper();
+
+ private:
+ virtual void BrowserChildProcessHostConnected(
+ const ChildProcessData& data) OVERRIDE;
+ virtual void BrowserChildProcessHostDisconnected(
+ const ChildProcessData& data) OVERRIDE;
+
+ int child_thread_count_;
+ scoped_refptr<MessageLoopRunner> runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(InProcessUtilityThreadHelper);
+};
+
} // namespace content
#endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service_unittest.cc ('k') | content/public/test/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698