Merge pull request #1199 from deepak1556/protocol_asar_patch
read files from asar archives in custom protocol
This commit is contained in:
commit
bb0e68e563
2 changed files with 46 additions and 7 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "atom/browser/net/url_request_string_job.h"
|
||||
#include "atom/browser/net/asar/url_request_asar_job.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/url_request/url_request_error_job.h"
|
||||
|
@ -88,13 +90,33 @@ void AdapterRequestJob::CreateStringJobAndStart(const std::string& mime_type,
|
|||
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
|
||||
real_job_ = new net::URLRequestFileJob(
|
||||
request(),
|
||||
network_delegate(),
|
||||
path,
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
|
||||
base::FilePath asar_path, relative_path;
|
||||
if (!asar::GetAsarArchivePath(path, &asar_path, &relative_path)) {
|
||||
real_job_ = new net::URLRequestFileJob(
|
||||
request(),
|
||||
network_delegate(),
|
||||
path,
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
|
||||
} else {
|
||||
auto archive = asar::GetOrCreateAsarArchive(asar_path);
|
||||
if (!archive)
|
||||
real_job_ = new net::URLRequestErrorJob(
|
||||
request(),
|
||||
network_delegate(),
|
||||
net::ERR_FILE_NOT_FOUND);
|
||||
|
||||
real_job_ = new asar::URLRequestAsarJob(
|
||||
request(),
|
||||
network_delegate(),
|
||||
archive,
|
||||
relative_path,
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
|
||||
}
|
||||
|
||||
real_job_->Start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue