Just use plain pointer for weak reference.

This commit is contained in:
Cheng Zhao 2014-09-25 20:38:12 +08:00
parent c95a93ef1c
commit 4006b6407c
10 changed files with 38 additions and 45 deletions

View file

@ -45,7 +45,9 @@ AsarProtocolHandler::AsarProtocolHandler(
const scoped_refptr<base::TaskRunner>& file_task_runner)
: file_task_runner_(file_task_runner) {}
AsarProtocolHandler::~AsarProtocolHandler() {}
AsarProtocolHandler::~AsarProtocolHandler() {
LOG(ERROR) << "~AsarProtocolHandler";
}
net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
net::URLRequest* request,
@ -60,7 +62,7 @@ net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
return new net::URLRequestFileJob(request, network_delegate, full_path,
file_task_runner_);
scoped_refptr<Archive> archive = archive_factory_.GetOrCreate(asar_path);
Archive* archive = archive_factory_.GetOrCreate(asar_path);
if (!archive)
return new net::URLRequestErrorJob(request, network_delegate,
net::ERR_FILE_NOT_FOUND);

View file

@ -6,6 +6,7 @@
#define ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
#include "atom/common/asar/archive_factory.h"
#include "base/memory/ref_counted.h"
#include "net/url_request/url_request_job_factory.h"
namespace base {

View file

@ -17,7 +17,7 @@ namespace asar {
URLRequestAsarJob::URLRequestAsarJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const scoped_refptr<Archive>& archive,
Archive* archive,
const base::FilePath& file_path,
const scoped_refptr<base::TaskRunner>& file_task_runner)
: net::URLRequestJob(request, network_delegate),
@ -31,7 +31,7 @@ URLRequestAsarJob::URLRequestAsarJob(
URLRequestAsarJob::~URLRequestAsarJob() {}
void URLRequestAsarJob::Start() {
if (!archive_->GetFileInfo(file_path_, &file_info_)) {
if (!archive_ || !archive_->GetFileInfo(file_path_, &file_info_)) {
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_FILE_NOT_FOUND));
return;

View file

@ -27,7 +27,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
public:
URLRequestAsarJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const scoped_refptr<Archive>& archive,
Archive* archive,
const base::FilePath& file_path,
const scoped_refptr<base::TaskRunner>& file_task_runner);
@ -53,7 +53,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
// Callback after data is asynchronously read from the file into |buf|.
void DidRead(scoped_refptr<net::IOBuffer> buf, int result);
const scoped_refptr<Archive> archive_;
Archive* archive_;
Archive::FileInfo file_info_;
base::FilePath file_path_;