Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / public / browser / resource_context.h
blob3a3fafe0d1aa6dc78d4834c34d216f44c530eec6
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_CONTEXT_H_
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_CONTEXT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/supports_user_data.h"
14 #include "build/build_config.h"
15 #include "content/common/content_export.h"
17 class GURL;
19 namespace net {
20 class ClientCertStore;
21 class HostResolver;
22 class KeygenHandler;
23 class URLRequestContext;
26 namespace content {
28 class AppCacheService;
30 // ResourceContext contains the relevant context information required for
31 // resource loading. It lives on the IO thread, although it is constructed on
32 // the UI thread. It must be destructed on the IO thread.
33 class CONTENT_EXPORT ResourceContext : public base::SupportsUserData {
34 public:
35 #if !defined(OS_IOS)
36 ResourceContext();
37 #endif
38 ~ResourceContext() override;
39 virtual net::HostResolver* GetHostResolver() = 0;
41 // DEPRECATED: This is no longer a valid given isolated apps/sites and
42 // storage partitioning. This getter returns the default context associated
43 // with a BrowsingContext.
44 virtual net::URLRequestContext* GetRequestContext() = 0;
46 // Get platform ClientCertStore. May return nullptr.
47 virtual scoped_ptr<net::ClientCertStore> CreateClientCertStore();
49 // Create a platform KeygenHandler and pass it to |callback|. The |callback|
50 // may be run synchronously.
51 virtual void CreateKeygenHandler(
52 uint32 key_size_in_bits,
53 const std::string& challenge_string,
54 const GURL& url,
55 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback);
57 // Returns a callback that can be invoked to get a random salt
58 // string that is used for creating media device IDs. The salt
59 // should be stored in the current user profile and should be reset
60 // if cookies are cleared. The default is an empty string.
62 // It is safe to hold on to the callback returned and use it without
63 // regard to the lifetime of ResourceContext, although in general
64 // you should not use it long after the profile has been destroyed.
66 // TODO(joi): We don't think it should be unnecessary to use this
67 // after ResourceContext goes away. There is likely an underying bug
68 // in the lifetime of ProfileIOData vs. ResourceProcessHost, where
69 // sometimes ProfileIOData has gone away before RPH has finished
70 // being torn down (on the IO thread). The current interface that
71 // allows using the salt object after ResourceContext has gone away
72 // was put in place to fix http://crbug.com/341211 but I intend to
73 // try to figure out how the lifetime should be fixed properly. The
74 // original interface was just a method that returns a string.
76 // TODO(perkj): Make this method pure virtual when crbug/315022 is
77 // fixed.
78 typedef base::Callback<std::string()> SaltCallback;
79 virtual SaltCallback GetMediaDeviceIDSalt();
82 } // namespace content
84 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_CONTEXT_H_