forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathappcache_subresource_url_factory.h
77 lines (62 loc) · 2.83 KB
/
appcache_subresource_url_factory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "url/gurl.h"
namespace network {
class SharedURLLoaderFactory;
}
namespace content {
class AppCacheHost;
class AppCacheRequestHandler;
class AppCacheServiceImpl;
// Implements the URLLoaderFactory mojom for AppCache subresource requests.
class CONTENT_EXPORT AppCacheSubresourceURLFactory
: public network::mojom::URLLoaderFactory {
public:
~AppCacheSubresourceURLFactory() override;
// Factory function to create an instance of the factory.
// The |host| parameter contains the appcache host instance. This is used
// to create the AppCacheRequestHandler instances for handling subresource
// requests. Returns true if the factory was successfully created.
static bool CreateURLLoaderFactory(
base::WeakPtr<AppCacheHost> host,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>
loader_factory_receiver);
// network::mojom::URLLoaderFactory implementation.
void CreateLoaderAndStart(
mojo::PendingReceiver<network::mojom::URLLoader> url_loader_receiver,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
override;
base::WeakPtr<AppCacheSubresourceURLFactory> GetWeakPtr();
private:
friend class AppCacheNetworkServiceBrowserTest;
// TODO(michaeln): Declare SubresourceLoader here and add unittests.
AppCacheSubresourceURLFactory(
scoped_refptr<network::SharedURLLoaderFactory> network_loader_factory,
base::WeakPtr<AppCacheHost> host);
void OnMojoDisconnect();
mojo::ReceiverSet<network::mojom::URLLoaderFactory> receivers_;
scoped_refptr<network::SharedURLLoaderFactory> network_loader_factory_;
base::WeakPtr<AppCacheHost> appcache_host_;
base::WeakPtrFactory<AppCacheSubresourceURLFactory> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory);
};
} // namespace content
#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_