Skip to content

Commit 0cfb681

Browse files
committed
Fix: nw.App.clearCache hang and it should be sync
Ref nwjs#4674
1 parent b8714d0 commit 0cfb681

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/api/nw_app_api.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ bool NwAppClearCacheFunction::RunNWSync(base::ListValue* response, std::string*
109109
BrowsingDataRemover::REMOVE_CACHE,
110110
BrowsingDataHelper::ALL);
111111
// BrowsingDataRemover deletes itself.
112+
base::MessageLoop::ScopedNestableTaskAllower allow(
113+
base::MessageLoop::current());
112114
run_loop_.Run();
115+
remover->RemoveObserver(this);
113116
return true;
114117
}
115118

src/resources/api_nw_app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ nw_binding.registerCustomHook(function(bindingsAPI) {
5656
apiFunctions.setHandleRequest('setProxyConfig', function() {
5757
sendRequest.sendRequestSync('nw.App.setProxyConfig', arguments, this.definition.parameters, {});
5858
});
59+
apiFunctions.setHandleRequest('clearCache', function() {
60+
sendRequest.sendRequestSync('nw.App.clearCache', arguments, this.definition.parameters, {});
61+
});
5962
apiFunctions.setHandleRequest('getProxyForURL', function() {
6063
return nwNatives.getProxyForURL.apply(this, arguments);
6164
});

0 commit comments

Comments
 (0)