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

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, 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
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 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser 63 // blink::mojom::ManifestManager implementation.
58 // process. 64 void HasManifest(const HasManifestCallback& callback) override;
59 void OnHasManifest(int request_id); 65 void RequestManifest(const RequestManifestCallback& callback) override;
60 void OnRequestManifest(int request_id); 66
61 void OnRequestManifestComplete(int request_id, 67 // Called when receiving a RequestManifest() call from the browser process.
68 void OnRequestManifestComplete(const RequestManifestCallback& callback,
62 const Manifest&, 69 const Manifest&,
63 const ManifestDebugInfo&); 70 const ManifestDebugInfo&);
64 71
65 void FetchManifest(); 72 void FetchManifest();
66 void OnManifestFetchComplete(const GURL& document_url, 73 void OnManifestFetchComplete(const GURL& document_url,
67 const blink::WebURLResponse& response, 74 const blink::WebURLResponse& response,
68 const std::string& data); 75 const std::string& data);
69 void ResolveCallbacks(ResolveState state); 76 void ResolveCallbacks(ResolveState state);
70 77
71 std::unique_ptr<ManifestFetcher> fetcher_; 78 std::unique_ptr<ManifestFetcher> fetcher_;
72 79
73 // Whether the RenderFrame may have an associated Manifest. If true, the frame 80 // Whether the RenderFrame may have an associated Manifest. If true, the frame
74 // may have a manifest, if false, it can't have one. This boolean is true when 81 // may have a manifest, if false, it can't have one. This boolean is true when
75 // DidChangeManifest() is called, if it is never called, it means that the 82 // DidChangeManifest() is called, if it is never called, it means that the
76 // associated document has no <link rel='manifest'>. 83 // associated document has no <link rel='manifest'>.
77 bool may_have_manifest_; 84 bool may_have_manifest_;
78 85
79 // Whether the current Manifest is dirty. 86 // Whether the current Manifest is dirty.
80 bool manifest_dirty_; 87 bool manifest_dirty_;
81 88
82 // Current Manifest. Might be outdated if manifest_dirty_ is true. 89 // Current Manifest. Might be outdated if manifest_dirty_ is true.
83 Manifest manifest_; 90 Manifest manifest_;
84 91
85 // Current Manifest debug information. 92 // Current Manifest debug information.
86 ManifestDebugInfo manifest_debug_info_; 93 ManifestDebugInfo manifest_debug_info_;
87 94
88 std::list<GetManifestCallback> pending_callbacks_; 95 std::vector<GetManifestCallback> pending_callbacks_;
96
97 mojo::BindingSet<blink::mojom::ManifestManager> bindings_;
89 98
90 DISALLOW_COPY_AND_ASSIGN(ManifestManager); 99 DISALLOW_COPY_AND_ASSIGN(ManifestManager);
91 }; 100 };
92 101
93 } // namespace content 102 } // namespace content
94 103
95 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ 104 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698