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

Unified Diff: content/browser/trace_subscriber_stdio_unittest.cc

Issue 9333003: Use FILE thread for disk operations in TraceSubscriberStdio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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/browser/trace_subscriber_stdio_unittest.cc
===================================================================
--- content/browser/trace_subscriber_stdio_unittest.cc (revision 120564)
+++ content/browser/trace_subscriber_stdio_unittest.cc (working copy)
@@ -5,10 +5,27 @@
#include "content/browser/trace_subscriber_stdio.h"
#include "base/scoped_temp_dir.h"
+#include "base/threading/thread_restrictions.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
+class ScopedDisallowIO {
+ public:
+ ScopedDisallowIO() {
+ previous_value_ = base::ThreadRestrictions::SetIOAllowed(false);
+ }
+
+ ~ScopedDisallowIO() {
+ base::ThreadRestrictions::SetIOAllowed(previous_value_);
+ }
+
+ private:
+ bool previous_value_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedDisallowIO);
+};
+
class TraceSubscriberStdioTest : public testing::Test {
public:
virtual void SetUp() {
@@ -29,6 +46,10 @@
} // namespace
TEST_F(TraceSubscriberStdioTest, CanWriteDataToFile) {
+ // TraceSubscriber callbacks are documented to occur on the UI thread,
+ // so this class must work with ThreadRestictions::SetIOAllowed(false);
+ ScopedDisallowIO scoped_disallow_io;
+
TraceSubscriberStdio subscriber(trace_file_);
subscriber.OnTraceDataCollected("[foo]");
subscriber.OnTraceDataCollected("[bar]");
@@ -37,4 +58,3 @@
subscriber.OnEndTracingComplete();
EXPECT_FALSE(subscriber.IsValid());
}
-
« content/browser/trace_subscriber_stdio.cc ('K') | « content/browser/trace_subscriber_stdio.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698