Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: content/browser/appcache/appcache_subresource_url_factory.h

Issue 2991443002: The Appcache subresource URL factory needs to inform the URLLoaderClient if there is a failure. (Closed)
Patch Set: Provide a way to turn off certain errors like missing host etc in the factory for tests. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_SUBRESOURCE_URL_FACTORY_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "content/common/content_export.h"
10 #include "content/public/common/url_loader_factory.mojom.h" 11 #include "content/public/common/url_loader_factory.mojom.h"
11 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
12 #include "net/traffic_annotation/network_traffic_annotation.h" 13 #include "net/traffic_annotation/network_traffic_annotation.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 class AppCacheHost; 18 class AppCacheHost;
18 class AppCacheJob; 19 class AppCacheJob;
19 class AppCacheServiceImpl; 20 class AppCacheServiceImpl;
20 class URLLoaderFactoryGetter; 21 class URLLoaderFactoryGetter;
21 22
22 // Implements the URLLoaderFactory mojom for AppCache subresource requests. 23 // Implements the URLLoaderFactory mojom for AppCache subresource requests.
23 class AppCacheSubresourceURLFactory : public mojom::URLLoaderFactory { 24 class CONTENT_EXPORT AppCacheSubresourceURLFactory
25 : public mojom::URLLoaderFactory {
24 public: 26 public:
25 ~AppCacheSubresourceURLFactory() override; 27 ~AppCacheSubresourceURLFactory() override;
26 28
27 // Factory function to create an instance of the factory. 29 // Factory function to create an instance of the factory.
28 // 1. The |factory_getter| parameter is used to query the network service 30 // 1. The |factory_getter| parameter is used to query the network service
29 // to pass network requests to. 31 // to pass network requests to.
30 // 2. The |host| parameter contains the appcache host instance. This is used 32 // 2. The |host| parameter contains the appcache host instance. This is used
31 // to create the AppCacheRequestHandler instances for handling subresource 33 // to create the AppCacheRequestHandler instances for handling subresource
32 // requests. 34 // requests.
33 // Returns the AppCacheSubresourceURLFactory instance. The URLLoaderFactoryPtr 35 // Returns the AppCacheSubresourceURLFactory instance. The URLLoaderFactoryPtr
(...skipping 12 matching lines...) Expand all
46 const ResourceRequest& request, 48 const ResourceRequest& request,
47 mojom::URLLoaderClientPtr client, 49 mojom::URLLoaderClientPtr client,
48 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) 50 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
49 override; 51 override;
50 void SyncLoad(int32_t routing_id, 52 void SyncLoad(int32_t routing_id,
51 int32_t request_id, 53 int32_t request_id,
52 const ResourceRequest& request, 54 const ResourceRequest& request,
53 SyncLoadCallback callback) override; 55 SyncLoadCallback callback) override;
54 56
55 private: 57 private:
58 friend class AppCacheNetworkServiceBrowserTest;
59
56 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request, 60 AppCacheSubresourceURLFactory(mojom::URLLoaderFactoryRequest request,
57 URLLoaderFactoryGetter* factory_getter, 61 URLLoaderFactoryGetter* factory_getter,
58 base::WeakPtr<AppCacheHost> host); 62 base::WeakPtr<AppCacheHost> host);
59 63
60 void OnConnectionError(); 64 void OnConnectionError();
61 65
66 // Notifies the |client| if there is a failure. The |error_code| contains the
67 // actual error.
68 void NotifyError(mojom::URLLoaderClientPtr client, int error_code);
69
70 // Passes a flag |for_testing| indicating that we are in test mode. Certain
71 // behaviors like returning errors for a missing host, etc are turned off in
jam 2017/07/25 15:00:51 this seems specific to this one test; it's not int
ananta 2017/07/25 22:26:49 Thanks. done. I had to create a custom embedded se
72 // this mode. Defaults to false.
73 static void SetForTesting(bool for_testing);
74
62 // Mojo binding. 75 // Mojo binding.
63 mojo::Binding<mojom::URLLoaderFactory> binding_; 76 mojo::Binding<mojom::URLLoaderFactory> binding_;
64 77
65 // Used to retrieve the network service factory to pass unhandled requests to 78 // Used to retrieve the network service factory to pass unhandled requests to
66 // the network service. 79 // the network service.
67 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; 80 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_;
68 81
69 base::WeakPtr<AppCacheHost> appcache_host_; 82 base::WeakPtr<AppCacheHost> appcache_host_;
70 83
71 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory); 84 DISALLOW_COPY_AND_ASSIGN(AppCacheSubresourceURLFactory);
72 }; 85 };
73 86
74 } // namespace content 87 } // namespace content
75 88
76 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_ 89 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_FACTORY_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_browsertest.cc ('k') | content/browser/appcache/appcache_subresource_url_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698