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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: fixed dcheck build error Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 class CORE_EXPORT StringCache { 77 class CORE_EXPORT StringCache {
78 USING_FAST_MALLOC(StringCache); 78 USING_FAST_MALLOC(StringCache);
79 WTF_MAKE_NONCOPYABLE(StringCache); 79 WTF_MAKE_NONCOPYABLE(StringCache);
80 80
81 public: 81 public:
82 explicit StringCache(v8::Isolate* isolate) : string_cache_(isolate) {} 82 explicit StringCache(v8::Isolate* isolate) : string_cache_(isolate) {}
83 83
84 v8::Local<v8::String> V8ExternalString(v8::Isolate* isolate, 84 v8::Local<v8::String> V8ExternalString(v8::Isolate* isolate,
85 StringImpl* string_impl) { 85 StringImpl* string_impl) {
86 ASSERT(string_impl); 86 DCHECK(string_impl);
87 if (last_string_impl_.Get() == string_impl) 87 if (last_string_impl_.Get() == string_impl)
88 return last_v8_string_.NewLocal(isolate); 88 return last_v8_string_.NewLocal(isolate);
89 return V8ExternalStringSlow(isolate, string_impl); 89 return V8ExternalStringSlow(isolate, string_impl);
90 } 90 }
91 91
92 void SetReturnValueFromString(v8::ReturnValue<v8::Value> return_value, 92 void SetReturnValueFromString(v8::ReturnValue<v8::Value> return_value,
93 StringImpl* string_impl) { 93 StringImpl* string_impl) {
94 ASSERT(string_impl); 94 DCHECK(string_impl);
95 if (last_string_impl_.Get() == string_impl) 95 if (last_string_impl_.Get() == string_impl)
96 last_v8_string_.SetReturnValue(return_value); 96 last_v8_string_.SetReturnValue(return_value);
97 else 97 else
98 SetReturnValueFromStringSlow(return_value, string_impl); 98 SetReturnValueFromStringSlow(return_value, string_impl);
99 } 99 }
100 100
101 void Dispose(); 101 void Dispose();
102 102
103 friend class StringCacheMapTraits; 103 friend class StringCacheMapTraits;
104 104
105 private: 105 private:
106 v8::Local<v8::String> V8ExternalStringSlow(v8::Isolate*, StringImpl*); 106 v8::Local<v8::String> V8ExternalStringSlow(v8::Isolate*, StringImpl*);
107 void SetReturnValueFromStringSlow(v8::ReturnValue<v8::Value>, StringImpl*); 107 void SetReturnValueFromStringSlow(v8::ReturnValue<v8::Value>, StringImpl*);
108 v8::Local<v8::String> CreateStringAndInsertIntoCache(v8::Isolate*, 108 v8::Local<v8::String> CreateStringAndInsertIntoCache(v8::Isolate*,
109 StringImpl*); 109 StringImpl*);
110 void InvalidateLastString(); 110 void InvalidateLastString();
111 111
112 StringCacheMapTraits::MapType string_cache_; 112 StringCacheMapTraits::MapType string_cache_;
113 StringCacheMapTraits::MapType::PersistentValueReference last_v8_string_; 113 StringCacheMapTraits::MapType::PersistentValueReference last_v8_string_;
114 114
115 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity 115 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity
116 // hence lastStringImpl might be not a key of the cache (in sense of identity) 116 // hence lastStringImpl might be not a key of the cache (in sense of identity)
117 // and hence it's not refed on addition. 117 // and hence it's not refed on addition.
118 RefPtr<StringImpl> last_string_impl_; 118 RefPtr<StringImpl> last_string_impl_;
119 }; 119 };
120 120
121 } // namespace blink 121 } // namespace blink
122 122
123 #endif // V8ValueCache_h 123 #endif // V8ValueCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698