Move GetsOrCreateAsarArchive to asar_util.h
This commit is contained in:
parent
64622ceae3
commit
3b3a025ed4
7 changed files with 66 additions and 25 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "atom/browser/net/asar/url_request_asar_job.h"
|
||||
#include "atom/common/asar/archive.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/url_request/url_request_error_job.h"
|
||||
|
@ -49,19 +50,6 @@ AsarProtocolHandler::AsarProtocolHandler(
|
|||
AsarProtocolHandler::~AsarProtocolHandler() {
|
||||
}
|
||||
|
||||
Archive* AsarProtocolHandler::GetOrCreateAsarArchive(
|
||||
const base::FilePath& path) const {
|
||||
if (!archives_.contains(path)) {
|
||||
scoped_ptr<Archive> archive(new Archive(path));
|
||||
if (!archive->Init())
|
||||
return nullptr;
|
||||
|
||||
archives_.set(path, archive.Pass());
|
||||
}
|
||||
|
||||
return archives_.get(path);
|
||||
}
|
||||
|
||||
net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
|
@ -75,7 +63,7 @@ net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
|
|||
return new net::URLRequestFileJob(request, network_delegate, full_path,
|
||||
file_task_runner_);
|
||||
|
||||
Archive* archive = GetOrCreateAsarArchive(asar_path);
|
||||
std::shared_ptr<Archive> archive = GetOrCreateAsarArchive(asar_path);
|
||||
if (!archive)
|
||||
return new net::URLRequestErrorJob(request, network_delegate,
|
||||
net::ERR_FILE_NOT_FOUND);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue