- 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:
Marshall Greenblatt 2010-11-09 21:06:39 +00:00
parent eaf976875f
commit 54e0a2db9a
3 changed files with 8 additions and 25 deletions

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BROWSER_WEB_WORKER_H_
#define BROWSER_WEB_WORKER_H_
#ifndef _BROWSER_WEB_WORKER_H
#define _BROWSER_WEB_WORKER_H
#include "base/basictypes.h"
#include "base/ref_counted.h"
@ -98,4 +98,4 @@ class BrowserWebWorker : public WebKit::WebWorker,
DISALLOW_COPY_AND_ASSIGN(BrowserWebWorker);
};
#endif // BROWSER_WEB_WORKER_H_
#endif // _BROWSER_WEB_WORKER_H

View File

@ -40,23 +40,6 @@ int XMLCALL xml_read_callback(void * context, char * buffer, int 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:
* @arg: the user argument
@ -177,12 +160,8 @@ bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
if (!input_buffer)
return false;
// Add a reference that will be released by xml_close_callback().
stream->AddRef();
input_buffer->context = stream.get();
input_buffer->readcallback = xml_read_callback;
input_buffer->closecallback = xml_close_callback;
// Create the text reader.
reader_ = xmlNewTextReader(input_buffer, WideToUTF8(URI).c_str());
@ -192,6 +171,9 @@ bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
return false;
}
// Keep a reference to the stream.
stream_ = stream;
// Register the error callbacks.
xmlTextReaderSetErrorHandler(reader_, xml_error_callback, this);
xmlTextReaderSetStructuredErrorHandler(reader_,

View File

@ -62,6 +62,7 @@ public:
protected:
PlatformThreadId supported_thread_id_;
CefRefPtr<CefStreamReader> stream_;
xmlTextReaderPtr reader_;
std::wstringstream error_buf_;
};