mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Fix a reference leak in CefXmlReaderImpl due to xml_close_callback not always being called.
- Make include guards consistent in browser_web_worker.h git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@134 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BROWSER_WEB_WORKER_H_
|
#ifndef _BROWSER_WEB_WORKER_H
|
||||||
#define BROWSER_WEB_WORKER_H_
|
#define _BROWSER_WEB_WORKER_H
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/ref_counted.h"
|
#include "base/ref_counted.h"
|
||||||
@ -98,4 +98,4 @@ class BrowserWebWorker : public WebKit::WebWorker,
|
|||||||
DISALLOW_COPY_AND_ASSIGN(BrowserWebWorker);
|
DISALLOW_COPY_AND_ASSIGN(BrowserWebWorker);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BROWSER_WEB_WORKER_H_
|
#endif // _BROWSER_WEB_WORKER_H
|
||||||
|
@ -40,23 +40,6 @@ int XMLCALL xml_read_callback(void * context, char * buffer, int len)
|
|||||||
return reader->Read(buffer, 1, len);
|
return reader->Read(buffer, 1, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlInputCloseCallback:
|
|
||||||
* @context: an Input context
|
|
||||||
*
|
|
||||||
* Callback used in the I/O Input API to close the resource
|
|
||||||
*
|
|
||||||
* Returns 0 or -1 in case of error
|
|
||||||
*/
|
|
||||||
int XMLCALL xml_close_callback(void * context)
|
|
||||||
{
|
|
||||||
CefRefPtr<CefStreamReader> reader(static_cast<CefStreamReader*>(context));
|
|
||||||
|
|
||||||
// Release the reference added by CefXmlReaderImpl::Initialize().
|
|
||||||
reader->Release();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlTextReaderErrorFunc:
|
* xmlTextReaderErrorFunc:
|
||||||
* @arg: the user argument
|
* @arg: the user argument
|
||||||
@ -177,12 +160,8 @@ bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
|
|||||||
if (!input_buffer)
|
if (!input_buffer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Add a reference that will be released by xml_close_callback().
|
|
||||||
stream->AddRef();
|
|
||||||
|
|
||||||
input_buffer->context = stream.get();
|
input_buffer->context = stream.get();
|
||||||
input_buffer->readcallback = xml_read_callback;
|
input_buffer->readcallback = xml_read_callback;
|
||||||
input_buffer->closecallback = xml_close_callback;
|
|
||||||
|
|
||||||
// Create the text reader.
|
// Create the text reader.
|
||||||
reader_ = xmlNewTextReader(input_buffer, WideToUTF8(URI).c_str());
|
reader_ = xmlNewTextReader(input_buffer, WideToUTF8(URI).c_str());
|
||||||
@ -192,6 +171,9 @@ bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep a reference to the stream.
|
||||||
|
stream_ = stream;
|
||||||
|
|
||||||
// Register the error callbacks.
|
// Register the error callbacks.
|
||||||
xmlTextReaderSetErrorHandler(reader_, xml_error_callback, this);
|
xmlTextReaderSetErrorHandler(reader_, xml_error_callback, this);
|
||||||
xmlTextReaderSetStructuredErrorHandler(reader_,
|
xmlTextReaderSetStructuredErrorHandler(reader_,
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
PlatformThreadId supported_thread_id_;
|
PlatformThreadId supported_thread_id_;
|
||||||
|
CefRefPtr<CefStreamReader> stream_;
|
||||||
xmlTextReaderPtr reader_;
|
xmlTextReaderPtr reader_;
|
||||||
std::wstringstream error_buf_;
|
std::wstringstream error_buf_;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user