OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ | 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ |
6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ | 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class RenderFrameHost; | 14 class RenderFrameHost; |
15 class WebContents; | 15 class WebContents; |
16 struct Manifest; | 16 struct Manifest; |
17 | 17 |
18 // ManifestManagerHost is a helper class that allows callers to get the Manifest | 18 // ManifestManagerHost is a helper class that allows callers to get the Manifest |
19 // associated with a frame. It handles the IPC messaging with the child process. | 19 // associated with a frame. It handles the IPC messaging with the child process. |
20 // TODO(mlamouri): keep a cached version and a dirty bit here. | 20 // TODO(mlamouri): keep a cached version and a dirty bit here. |
21 class ManifestManagerHost : public WebContentsObserver { | 21 class ManifestManagerHost : public WebContentsObserver { |
22 public: | 22 public: |
23 explicit ManifestManagerHost(WebContents* web_contents); | 23 explicit ManifestManagerHost(WebContents* web_contents); |
24 virtual ~ManifestManagerHost(); | 24 ~ManifestManagerHost() override; |
25 | 25 |
26 typedef base::Callback<void(const Manifest&)> GetManifestCallback; | 26 typedef base::Callback<void(const Manifest&)> GetManifestCallback; |
27 | 27 |
28 // Calls the given callback with the manifest associated with the | 28 // Calls the given callback with the manifest associated with the |
29 // given RenderFrameHost. If the frame has no manifest or if getting it failed | 29 // given RenderFrameHost. If the frame has no manifest or if getting it failed |
30 // the callback will have an empty manifest. | 30 // the callback will have an empty manifest. |
31 void GetManifest(RenderFrameHost*, const GetManifestCallback&); | 31 void GetManifest(RenderFrameHost*, const GetManifestCallback&); |
32 | 32 |
33 // WebContentsObserver | 33 // WebContentsObserver |
34 virtual bool OnMessageReceived(const IPC::Message&, | 34 bool OnMessageReceived(const IPC::Message&, RenderFrameHost*) override; |
35 RenderFrameHost*) override; | 35 void RenderFrameDeleted(RenderFrameHost*) override; |
36 virtual void RenderFrameDeleted(RenderFrameHost*) override; | |
37 | 36 |
38 private: | 37 private: |
39 typedef IDMap<GetManifestCallback, IDMapOwnPointer> CallbackMap; | 38 typedef IDMap<GetManifestCallback, IDMapOwnPointer> CallbackMap; |
40 typedef base::hash_map<RenderFrameHost*, CallbackMap*> FrameCallbackMap; | 39 typedef base::hash_map<RenderFrameHost*, CallbackMap*> FrameCallbackMap; |
41 | 40 |
42 void OnRequestManifestResponse( | 41 void OnRequestManifestResponse( |
43 RenderFrameHost*, int request_id, const Manifest&); | 42 RenderFrameHost*, int request_id, const Manifest&); |
44 | 43 |
45 // Returns the CallbackMap associated with the given RenderFrameHost, or null. | 44 // Returns the CallbackMap associated with the given RenderFrameHost, or null. |
46 CallbackMap* GetCallbackMapForFrame(RenderFrameHost*); | 45 CallbackMap* GetCallbackMapForFrame(RenderFrameHost*); |
47 | 46 |
48 FrameCallbackMap pending_callbacks_; | 47 FrameCallbackMap pending_callbacks_; |
49 | 48 |
50 DISALLOW_COPY_AND_ASSIGN(ManifestManagerHost); | 49 DISALLOW_COPY_AND_ASSIGN(ManifestManagerHost); |
51 }; | 50 }; |
52 | 51 |
53 } // namespace content | 52 } // namespace content |
54 | 53 |
55 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ | 54 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_HOST_H_ |
OLD | NEW |