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

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: update after r471804 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
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 allows code running
scottmg 2017/05/16 03:53:43 "for a given StoragePartition allows code" missing
jam 2017/05/16 04:08:50 Done.
17 // on the IO thread to access them. Note these are the factories used by the
18 // browser process for frame requests.
19 class CONTENT_EXPORT URLLoaderFactoryGetter
20 : public base::RefCountedThreadSafe<URLLoaderFactoryGetter,
21 BrowserThread::DeleteOnIOThread> {
22 public:
23 URLLoaderFactoryGetter();
24 ~URLLoaderFactoryGetter();
25
26 // Initializes this object on the UI thread.
27 void Initialize(mojom::URLLoaderFactoryPtr network_factory);
28
29 // Called on the IO thread to get the URLLoaderFactory to the network service.
30 // The pointer shouldn't be cached.
31 mojom::URLLoaderFactoryPtr* GetNetworkFactory();
32
33 // Overrides the network URLLoaderFactory for subsequent requests. Passing a
34 // null pointer will restore the default behavior.
35 // This is called on the UI thread.
36 void SetNetworkFactoryForTesting(mojom::URLLoaderFactoryPtr test_factory);
37
38 private:
39 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
40
41 void InitializeOnIOThread(mojom::URLLoaderFactoryPtrInfo network_factory);
42 void SetTestNetworkFactoryOnIOThread(
43 mojom::URLLoaderFactoryPtrInfo test_factory);
44
45 // Only accessed on IO thread.
46 mojom::URLLoaderFactoryPtr network_factory_;
47 mojom::URLLoaderFactoryPtr test_factory_;
48
49 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryGetter);
50 };
51
52 } // namespace content
53
54 #endif // CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698