Skip to content

Commit 2f09ac5

Browse files
CzarekCzarek
authored andcommitted
Added RequestHandler.GetDownloadHandler and DownloadHandler.
Added download handler test to the wxpython.py script. Temporary fix for memory corruption due to buggy implementation of weakrefs for Extension types in Cython.
1 parent 074b0ba commit 2f09ac5

21 files changed

+493
-98
lines changed

cefpython/cef1/client_handler/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC = g++
22
CCFLAGS = -g
33

4-
SRC = client_handler.cpp web_request_client.cpp content_filter_handler.cpp cookie_visitor.cpp
4+
SRC = client_handler.cpp web_request_client.cpp content_filter_handler.cpp cookie_visitor.cpp download_handler.cpp
55
OBJ = $(SRC:.cpp=.o)
66
OUT = libclient_handler.a
77

cefpython/cef1/client_handler/client_handler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ bool ClientHandler::GetDownloadHandler(
148148
int64 contentLength,
149149
CefRefPtr<CefDownloadHandler>& handler) {
150150
REQUIRE_UI_THREAD();
151-
return RequestHandler_GetDownloadHandler(
152-
browser, const_cast<CefString&>(mimeType),
153-
const_cast<CefString&>(fileName), contentLength, handler);
151+
return RequestHandler_GetDownloadHandler(browser, mimeType, fileName,
152+
contentLength, handler);
154153
}
155154

156155
bool ClientHandler::GetAuthCredentials(

cefpython/cef1/client_handler/content_filter_handler.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ class ContentFilterHandler : public CefContentFilter
2222
virtual void Drain(CefRefPtr<CefStreamReader>& remainder) OVERRIDE;
2323

2424
protected:
25-
2625
// Include the default reference counting implementation.
2726
IMPLEMENT_REFCOUNTING(ContentFilterHandler);
28-
29-
// Include the default locking implementation.
30-
IMPLEMENT_LOCKING(ContentFilterHandler);
31-
3227
};

cefpython/cef1/client_handler/cookie_visitor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ class CookieVisitor : public CefCookieVisitor
2323
) OVERRIDE;
2424

2525
protected:
26-
2726
// Include the default reference counting implementation.
2827
IMPLEMENT_REFCOUNTING(CookieVisitor);
29-
30-
// Include the default locking implementation.
31-
IMPLEMENT_LOCKING(CookieVisitor);
32-
3328
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
2+
// License: New BSD License.
3+
// Website: http://code.google.com/p/cefpython/
4+
5+
#include "download_handler.h"
6+
#include <stdio.h>
7+
8+
bool DownloadHandler::ReceivedData(
9+
void* data,
10+
int data_size
11+
) {
12+
REQUIRE_UI_THREAD();
13+
if (data_size == 0)
14+
return true;
15+
return DownloadHandler_ReceivedData(downloadHandlerId_, data, data_size);
16+
}
17+
18+
void DownloadHandler::Complete() {
19+
REQUIRE_UI_THREAD();
20+
DownloadHandler_Complete(downloadHandlerId_);
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
2+
// License: New BSD License.
3+
// Website: http://code.google.com/p/cefpython/
4+
5+
#pragma once
6+
7+
#include "cefpython_public_api.h"
8+
9+
class DownloadHandler : public CefDownloadHandler
10+
{
11+
public:
12+
int downloadHandlerId_;
13+
public:
14+
DownloadHandler(int downloadHandlerId)
15+
: downloadHandlerId_(downloadHandlerId) {
16+
}
17+
18+
virtual bool ReceivedData(void* data, int data_size) OVERRIDE;
19+
virtual void Complete() OVERRIDE;
20+
21+
protected:
22+
// Include the default reference counting implementation.
23+
IMPLEMENT_REFCOUNTING(DownloadHandler);
24+
};

cefpython/cef1/client_handler/web_request_client.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class WebRequestClient : public CefWebURLRequestClient
3535
virtual void OnError(CefRefPtr<CefWebURLRequest> requester,
3636
ErrorCode errorCode) OVERRIDE;
3737
protected:
38-
3938
// Include the default reference counting implementation.
4039
IMPLEMENT_REFCOUNTING(WebRequestClient);
41-
42-
// Include the default locking implementation.
43-
IMPLEMENT_LOCKING(WebRequestClient);
44-
4540
};

cefpython/cef1/linux/binaries_32bit/wxpython.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,26 @@ <h3>Cookie tests</h3>
147147

148148

149149

150-
<h3>DragHandler tests</h3>
150+
<h3>DragHandler test</h3>
151151

152152
Try dragging a file, or a text/html fragment to the browser window
153153
and look for the messages in the console. In the wxpython.py script see
154154
ClientHandler.OnDragStart() and OnDragEnter().
155155

156156

157157

158+
159+
<h3>DownloadHandler test</h3>
160+
161+
Try downloading this file (838 KiB):<br>
162+
<a href="http://cefpython.googlecode.com/files/ubuntu-wallpapers2.zip">
163+
http://cefpython.googlecode.com/files/ubuntu-wallpapers2.zip</a>
164+
<br>
165+
See messages in the console.
166+
The file will be saved in the ./downloads/ directory.
167+
168+
169+
170+
158171
</body>
159172
</html>

0 commit comments

Comments
 (0)