electron/atom/browser/net/asar/asar_protocol_handler.h

46 lines
1.3 KiB
C
Raw Normal View History

// Copyright (c) 2014 GitHub, Inc.
2014-09-23 04:13:46 +00:00
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
#define ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
2014-09-25 13:54:59 +00:00
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
2014-09-23 04:13:46 +00:00
#include "net/url_request/url_request_job_factory.h"
namespace base {
class TaskRunner;
}
namespace asar {
2014-09-25 13:54:59 +00:00
class Archive;
2014-09-23 04:13:46 +00:00
class AsarProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
explicit AsarProtocolHandler(
const scoped_refptr<base::TaskRunner>& file_task_runner);
virtual ~AsarProtocolHandler();
2014-09-25 13:54:59 +00:00
Archive* GetOrCreateAsarArchive(const base::FilePath& path) const;
2014-09-23 04:13:46 +00:00
// net::URLRequestJobFactory::ProtocolHandler:
virtual net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE;
virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE;
private:
const scoped_refptr<base::TaskRunner> file_task_runner_;
2014-09-25 13:54:59 +00:00
mutable base::ScopedPtrHashMap<base::FilePath, Archive> archives_;
2014-09-23 13:48:40 +00:00
2014-09-23 04:13:46 +00:00
DISALLOW_COPY_AND_ASSIGN(AsarProtocolHandler);
};
} // namespace asar
#endif // ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_