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

Side by Side Diff: content/renderer/manifest/manifest_manager.h

Issue 1913043002: Convert ManifestManager IPCs to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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_H_ 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_
6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_
7 7
8 #include <list>
9 #include <memory> 8 #include <memory>
9 #include <string>
10 #include <vector>
10 11
11 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "content/public/common/manifest.h" 14 #include "content/public/common/manifest.h"
14 #include "content/public/renderer/render_frame_observer.h" 15 #include "content/public/renderer/render_frame_observer.h"
15 #include "content/renderer/manifest/manifest_debug_info.h" 16 #include "content/renderer/manifest/manifest_debug_info.h"
17 #include "mojo/public/cpp/bindings/binding_set.h"
18 #include "third_party/WebKit/public/platform/modules/manifest/manifest.mojom.h"
19 #include "third_party/WebKit/public/platform/modules/manifest/manifest_manager.m ojom.h"
16 20
17 class GURL; 21 class GURL;
18 22
19 namespace blink { 23 namespace blink {
20 class WebURLResponse; 24 class WebURLResponse;
21 } 25 }
22 26
23 namespace content { 27 namespace content {
24 28
25 class ManifestFetcher; 29 class ManifestFetcher;
26 30
27 // The ManifestManager is a helper class that takes care of fetching and parsing 31 // The ManifestManager is a helper class that takes care of fetching and parsing
28 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and 32 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and
29 // the ManifestParser in order to do so. 33 // the ManifestParser in order to do so.
30 // There are two expected consumers of this helper: ManifestManagerHost, via IPC 34 // There are two expected consumers of this helper: ManifestManagerHost, via IPC
31 // messages and callers inside the renderer process. The latter should use 35 // messages and callers inside the renderer process. The latter should use
32 // GetManifest(). 36 // GetManifest().
33 class ManifestManager : public RenderFrameObserver { 37 class ManifestManager : public RenderFrameObserver,
38 public blink::mojom::ManifestManager {
34 public: 39 public:
35 typedef base::Callback<void(const Manifest&, 40 typedef base::Callback<void(const Manifest&,
36 const ManifestDebugInfo&)> GetManifestCallback; 41 const ManifestDebugInfo&)> GetManifestCallback;
37 42
38 explicit ManifestManager(RenderFrame* render_frame); 43 explicit ManifestManager(RenderFrame* render_frame);
39 ~ManifestManager() override; 44 ~ManifestManager() override;
40 45
41 // Will call the given |callback| with the Manifest associated with the 46 // Will call the given |callback| with the Manifest associated with the
42 // RenderFrame if any. Will pass an empty Manifest in case of error. 47 // RenderFrame if any. Will pass an empty Manifest in case of error.
43 void GetManifest(const GetManifestCallback& callback); 48 void GetManifest(const GetManifestCallback& callback);
44 49
45 // RenderFrameObserver implementation. 50 // RenderFrameObserver implementation.
46 bool OnMessageReceived(const IPC::Message& message) override;
47 void DidChangeManifest() override; 51 void DidChangeManifest() override;
48 void DidCommitProvisionalLoad(bool is_new_navigation, 52 void DidCommitProvisionalLoad(bool is_new_navigation,
49 bool is_same_page_navigation) override; 53 bool is_same_page_navigation) override;
50 54
55 void BindToRequest(blink::mojom::ManifestManagerRequest request);
56
51 private: 57 private:
52 enum ResolveState { 58 enum ResolveState {
53 ResolveStateSuccess, 59 ResolveStateSuccess,
54 ResolveStateFailure 60 ResolveStateFailure
55 }; 61 };
56 62
57 // RenderFrameObserver implementation. 63 // RenderFrameObserver implementation.
58 void OnDestruct() override; 64 void OnDestruct() override;
59 65
60 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser 66 // blink::mojom::ManifestManager implementation.
61 // process. 67 void HasManifest(const HasManifestCallback& callback) override;
62 void OnHasManifest(int request_id); 68 void RequestManifest(const RequestManifestCallback& callback) override;
63 void OnRequestManifest(int request_id); 69
64 void OnRequestManifestComplete(int request_id, 70 // Called when receiving a RequestManifest() call from the browser process.
71 void OnRequestManifestComplete(const RequestManifestCallback& callback,
65 const Manifest&, 72 const Manifest&,
66 const ManifestDebugInfo&); 73 const ManifestDebugInfo&);
67 74
68 void FetchManifest(); 75 void FetchManifest();
69 void OnManifestFetchComplete(const GURL& document_url, 76 void OnManifestFetchComplete(const GURL& document_url,
70 const blink::WebURLResponse& response, 77 const blink::WebURLResponse& response,
71 const std::string& data); 78 const std::string& data);
72 void ResolveCallbacks(ResolveState state); 79 void ResolveCallbacks(ResolveState state);
73 80
74 std::unique_ptr<ManifestFetcher> fetcher_; 81 std::unique_ptr<ManifestFetcher> fetcher_;
75 82
76 // Whether the RenderFrame may have an associated Manifest. If true, the frame 83 // Whether the RenderFrame may have an associated Manifest. If true, the frame
77 // may have a manifest, if false, it can't have one. This boolean is true when 84 // may have a manifest, if false, it can't have one. This boolean is true when
78 // DidChangeManifest() is called, if it is never called, it means that the 85 // DidChangeManifest() is called, if it is never called, it means that the
79 // associated document has no <link rel='manifest'>. 86 // associated document has no <link rel='manifest'>.
80 bool may_have_manifest_; 87 bool may_have_manifest_;
81 88
82 // Whether the current Manifest is dirty. 89 // Whether the current Manifest is dirty.
83 bool manifest_dirty_; 90 bool manifest_dirty_;
84 91
85 // Current Manifest. Might be outdated if manifest_dirty_ is true. 92 // Current Manifest. Might be outdated if manifest_dirty_ is true.
86 Manifest manifest_; 93 Manifest manifest_;
87 94
88 // Current Manifest debug information. 95 // Current Manifest debug information.
89 ManifestDebugInfo manifest_debug_info_; 96 ManifestDebugInfo manifest_debug_info_;
90 97
91 std::list<GetManifestCallback> pending_callbacks_; 98 std::vector<GetManifestCallback> pending_callbacks_;
99
100 mojo::BindingSet<blink::mojom::ManifestManager> bindings_;
92 101
93 DISALLOW_COPY_AND_ASSIGN(ManifestManager); 102 DISALLOW_COPY_AND_ASSIGN(ManifestManager);
94 }; 103 };
95 104
96 } // namespace content 105 } // namespace content
97 106
98 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ 107 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698