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

Side by Side Diff: content/browser/url_loader_factory_getter.h

Issue 2874163004: Add support in the network service for different contexts. (Closed)
Patch Set: review comment and clang fixes Created 3 years, 7 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
« no previous file with comments | « content/browser/storage_partition_impl.cc ('k') | content/browser/url_loader_factory_getter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_
6 #define CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h"
11 #include "content/common/url_loader_factory.mojom.h"
12 #include "content/public/browser/browser_thread.h"
13
14 namespace content {
15
16 // Holds on to URLLoaderFactory for a given StoragePartition and allows code
17 // running on the IO thread to access them. Note these are the factories used by
18 // the browser process for frame requests.
19 class URLLoaderFactoryGetter
20 : public base::RefCountedThreadSafe<URLLoaderFactoryGetter,
21 BrowserThread::DeleteOnIOThread> {
22 public:
23 URLLoaderFactoryGetter();
24
25 // Initializes this object on the UI thread.
26 void Initialize(mojom::URLLoaderFactoryPtr network_factory);
27
28 // Called on the IO thread to get the URLLoaderFactory to the network service.
29 // The pointer shouldn't be cached.
30 mojom::URLLoaderFactoryPtr* GetNetworkFactory();
31
32 // Overrides the network URLLoaderFactory for subsequent requests. Passing a
33 // null pointer will restore the default behavior.
34 // This is called on the UI thread.
35 CONTENT_EXPORT void SetNetworkFactoryForTesting(
36 mojom::URLLoaderFactoryPtr test_factory);
37
38 private:
39 friend class base::DeleteHelper<URLLoaderFactoryGetter>;
40 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
41
42 CONTENT_EXPORT ~URLLoaderFactoryGetter();
43 void InitializeOnIOThread(mojom::URLLoaderFactoryPtrInfo network_factory);
44 void SetTestNetworkFactoryOnIOThread(
45 mojom::URLLoaderFactoryPtrInfo test_factory);
46
47 // Only accessed on IO thread.
48 mojom::URLLoaderFactoryPtr network_factory_;
49 mojom::URLLoaderFactoryPtr test_factory_;
50
51 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryGetter);
52 };
53
54 } // namespace content
55
56 #endif // CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl.cc ('k') | content/browser/url_loader_factory_getter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698