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

Unified Diff: webkit/port/bindings/v8/v8_binding.cpp

Issue 99174: Artificially increase the ref count on WebCore strings that we use as... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/port/bindings/v8/v8_binding.cpp
===================================================================
--- webkit/port/bindings/v8/v8_binding.cpp (revision 14831)
+++ webkit/port/bindings/v8/v8_binding.cpp (working copy)
@@ -19,9 +19,30 @@
class WebCoreStringResource: public v8::String::ExternalStringResource {
public:
explicit WebCoreStringResource(const String& str)
- : impl_(str.impl()) { }
+ : impl_(str.impl()) {
+ // We seem to be occasionally losing the backing string for external
+ // strings: http://crbug.com/9746
+ //
+ // In order to verify that this is caused by a ref counting bug, we
+ // artificially increase the ref count on the backing string until
+ // we are done using it for external strings.
+ //
+ // TODO(ager): This is temporary and should be removed once we have
+ // found the underlying cause of the problem.
+ for (int i = 0; i < kArtificialRefIncrease; i++) {
+ impl_.impl()->ref();
+ }
+ }
- virtual ~WebCoreStringResource() {}
+ virtual ~WebCoreStringResource() {
+ // Remove the artificial ref counts added in the constructor.
+ //
+ // TODO(ager): This is temporary and should be removed once we have
+ // found the underlying cause of the problem.
+ for (int i = 0; i < kArtificialRefIncrease; i++) {
+ impl_.impl()->deref();
+ }
+ }
const uint16_t* data() const {
return reinterpret_cast<const uint16_t*>(impl_.characters());
@@ -32,6 +53,13 @@
String webcore_string() { return impl_; }
private:
+ // The amount by which we artificially increase the reference count
+ // of the backing string.
+ //
+ // TODO(ager): This is temporary and should be removed once we have
+ // found the underlying cause of the problem.
+ static const int kArtificialRefIncrease = 5;
+
// A shallow copy of the string.
// Keeps the string buffer alive until the V8 engine garbage collects it.
String impl_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698