Make sure webrtc::VideoSourceInterface is released on the main render thread.
[chromium-blink-merge.git] / content / public / browser / resource_context.h
blob58eb298987bce1cfb5251d125b6a50a2ebda56a3
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 appcache {
20 class AppCacheService;
23 namespace net {
24 class ClientCertStore;
25 class HostResolver;
26 class KeygenHandler;
27 class URLRequestContext;
30 namespace content {
32 // ResourceContext contains the relevant context information required for
33 // resource loading. It lives on the IO thread, although it is constructed on
34 // the UI thread. It must be destructed on the IO thread.
35 class CONTENT_EXPORT ResourceContext : public base::SupportsUserData {
36 public:
37 #if defined(OS_IOS)
38 virtual ~ResourceContext() {}
39 #else
40 ResourceContext();
41 virtual ~ResourceContext();
42 #endif
43 virtual net::HostResolver* GetHostResolver() = 0;
45 // DEPRECATED: This is no longer a valid given isolated apps/sites and
46 // storage partitioning. This getter returns the default context associated
47 // with a BrowsingContext.
48 virtual net::URLRequestContext* GetRequestContext() = 0;
50 // Get platform ClientCertStore. May return NULL.
51 virtual scoped_ptr<net::ClientCertStore> CreateClientCertStore();
53 // Create a platform KeygenHandler and pass it to |callback|. The |callback|
54 // may be run synchronously.
55 virtual void CreateKeygenHandler(
56 uint32 key_size_in_bits,
57 const std::string& challenge_string,
58 const GURL& url,
59 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback);
61 // Returns true if microphone access is allowed for |origin|. Used to
62 // determine what level of authorization is given to |origin| to access
63 // resource metadata.
64 virtual bool AllowMicAccess(const GURL& origin) = 0;
66 // Returns true if web camera access is allowed for |origin|. Used to
67 // determine what level of authorization is given to |origin| to access
68 // resource metadata.
69 virtual bool AllowCameraAccess(const GURL& origin) = 0;
71 // Returns a callback that can be invoked to get a random salt
72 // string that is used for creating media device IDs. The salt
73 // should be stored in the current user profile and should be reset
74 // if cookies are cleared. The default is an empty string.
76 // It is safe to hold on to the callback returned and use it without
77 // regard to the lifetime of ResourceContext, although in general
78 // you should not use it long after the profile has been destroyed.
80 // TODO(joi): We don't think it should be unnecessary to use this
81 // after ResourceContext goes away. There is likely an underying bug
82 // in the lifetime of ProfileIOData vs. ResourceProcessHost, where
83 // sometimes ProfileIOData has gone away before RPH has finished
84 // being torn down (on the IO thread). The current interface that
85 // allows using the salt object after ResourceContext has gone away
86 // was put in place to fix http://crbug.com/341211 but I intend to
87 // try to figure out how the lifetime should be fixed properly. The
88 // original interface was just a method that returns a string.
90 // TODO(perkj): Make this method pure virtual when crbug/315022 is
91 // fixed.
92 typedef base::Callback<std::string()> SaltCallback;
93 virtual SaltCallback GetMediaDeviceIDSalt();
96 } // namespace content
98 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_CONTEXT_H_