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

Unified Diff: test/cctest/cctest.h

Issue 2304553002: Include only stuff you need, part 6: Fix cctest.h. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | test/cctest/cctest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index dac3a5b94f91dac4b20c5215b3f602ec631d8dbc..333078a144efd476b3386a7d2cd28b3801bdd269 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -28,11 +28,30 @@
#ifndef CCTEST_H_
#define CCTEST_H_
+#include <memory>
+
#include "include/libplatform/libplatform.h"
-#include "src/isolate-inl.h" // TODO(everyone): Make cctest IWYU.
-#include "src/objects-inl.h" // TODO(everyone): Make cctest IWYU.
+#include "include/v8-debug.h"
+#include "src/base/accounting-allocator.h"
+#include "src/utils.h"
#include "src/v8.h"
+namespace v8 {
+namespace base {
+
+class RandomNumberGenerator;
+
+} // namespace base
+
+namespace internal {
+
+class HandleScope;
+class Zone;
+
+} // namespace internal
+
+} // namespace v8
+
#ifndef TEST
#define TEST(Name) \
static void Test##Name(); \
@@ -104,17 +123,11 @@ class CcTest {
return reinterpret_cast<i::Isolate*>(isolate());
}
- static i::Heap* heap() {
- return i_isolate()->heap();
- }
+ static i::Heap* heap();
- static v8::base::RandomNumberGenerator* random_number_generator() {
- return InitIsolateOnce()->random_number_generator();
- }
+ static v8::base::RandomNumberGenerator* random_number_generator();
- static v8::Local<v8::Object> global() {
- return isolate()->GetCurrentContext()->Global();
- }
+ static v8::Local<v8::Object> global();
static v8::ArrayBuffer::Allocator* array_buffer_allocator() {
return allocator_;
@@ -127,13 +140,7 @@ class CcTest {
// TODO(dcarney): Remove.
// This must be called first in a test.
- static void InitializeVM() {
- CHECK(!v8::base::NoBarrier_Load(&isolate_used_));
- CHECK(!initialize_called_);
- initialize_called_ = true;
- v8::HandleScope handle_scope(CcTest::isolate());
- v8::Context::New(CcTest::isolate())->Enter();
- }
+ static void InitializeVM();
// Only for UNINITIALIZED_TESTs
static void DisableAutomaticDispose();
@@ -144,9 +151,7 @@ class CcTest {
CcTestExtensionFlags extensions,
v8::Isolate* isolate = CcTest::isolate());
- static void TearDown() {
- if (isolate_ != NULL) isolate_->Dispose();
- }
+ static void TearDown();
private:
friend int main(int argc, char** argv);
@@ -269,11 +274,7 @@ class LocalContext {
Initialize(CcTest::isolate(), extensions, global_template, global_object);
}
- virtual ~LocalContext() {
- v8::HandleScope scope(isolate_);
- v8::Local<v8::Context>::New(isolate_, context_)->Exit();
- context_.Reset();
- }
+ virtual ~LocalContext();
v8::Context* operator->() {
return *reinterpret_cast<v8::Context**>(&context_);
@@ -288,17 +289,7 @@ class LocalContext {
private:
void Initialize(v8::Isolate* isolate, v8::ExtensionConfiguration* extensions,
v8::Local<v8::ObjectTemplate> global_template,
- v8::Local<v8::Value> global_object) {
- v8::HandleScope scope(isolate);
- v8::Local<v8::Context> context = v8::Context::New(isolate,
- extensions,
- global_template,
- global_object);
- context_.Reset(isolate, context);
- context->Enter();
- // We can't do this later perhaps because of a fatal error.
- isolate_ = isolate;
- }
+ v8::Local<v8::Value> global_object);
v8::Persistent<v8::Context> context_;
v8::Isolate* isolate_;
@@ -567,32 +558,33 @@ static inline void EmptyMessageQueues(v8::Isolate* isolate) {
}
}
+class InitializedHandleScopeImpl;
class InitializedHandleScope {
public:
- InitializedHandleScope()
- : main_isolate_(CcTest::InitIsolateOnce()),
- handle_scope_(main_isolate_) {}
+ InitializedHandleScope();
+ ~InitializedHandleScope();
// Prefixing the below with main_ reduces a lot of naming clashes.
i::Isolate* main_isolate() { return main_isolate_; }
private:
i::Isolate* main_isolate_;
- i::HandleScope handle_scope_;
+ std::unique_ptr<InitializedHandleScopeImpl> initialized_handle_scope_impl_;
};
class HandleAndZoneScope : public InitializedHandleScope {
public:
- HandleAndZoneScope() : main_zone_(&allocator_) {}
+ HandleAndZoneScope();
+ ~HandleAndZoneScope();
// Prefixing the below with main_ reduces a lot of naming clashes.
- i::Zone* main_zone() { return &main_zone_; }
+ i::Zone* main_zone() { return main_zone_.get(); }
private:
v8::base::AccountingAllocator allocator_;
- i::Zone main_zone_;
+ std::unique_ptr<i::Zone> main_zone_;
};
#endif // ifndef CCTEST_H_
« no previous file with comments | « no previous file | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698