feat: migrate protocol module to NetworkService (Part 7) (#18290)

* fix: make IsProtocolHandled return true for builtin schemes

* fix: return ERR_NOT_IMPLEMENTED for wrong arg

* Initial work of AsarURLLoader

* Put normal file logics in AsarURLLoader

* Implement asar file reading

* Don't change URL for unpacked file

* Fix cpplint warning
This commit is contained in:
Cheng Zhao 2019-05-15 08:29:58 +09:00 committed by GitHub
parent fde3137b90
commit 2ad62cedc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 340 additions and 5 deletions

View file

@ -10,6 +10,7 @@
#include "atom/browser/api/atom_api_session.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/asar/asar_url_loader.h"
#include "atom/browser/net/node_stream_loader.h"
#include "atom/common/atom_constants.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
@ -18,7 +19,6 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/guid.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/file_url_loader.h"
#include "content/public/browser/storage_partition.h"
#include "mojo/public/cpp/system/string_data_pipe_producer.h"
#include "net/base/filename_util.h"
@ -199,7 +199,8 @@ void AtomURLLoaderFactory::StartLoading(
// Some protocol accepts non-object responses.
if (dict.IsEmpty() && ResponseMustBeObject(type)) {
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
client->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_NOT_IMPLEMENTED));
return;
}
@ -291,8 +292,8 @@ void AtomURLLoaderFactory::StartLoadingFile(
network::ResourceResponseHead head = ToResponseHead(dict);
head.headers->AddHeader(kCORSHeader);
content::CreateFileURLLoader(request, std::move(loader), std::move(client),
nullptr, false, head.headers);
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
head.headers);
}
// static