Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | |
| 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "content/public/common/manifest.h" | |
| 13 #include "content/public/renderer/render_frame_observer.h" | |
| 14 | |
| 15 namespace blink { | |
| 16 class WebURLResponse; | |
| 17 } | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 class ManifestFetcher; | |
| 22 | |
| 23 // The ManifestManager is a helper class that takes care of fetching and parsing | |
| 24 // the Manifest of the associated RenderFrame. It uses the ManifestFetcher and | |
| 25 // the ManifestParser in order to do so. | |
| 26 // There are two expected consumers of this helper: ManifestManagerHost, via IPC | |
| 27 // messages and callers inside the renderer process. The latter should use | |
| 28 // GetManifest(). | |
| 29 class ManifestManager : public RenderFrameObserver { | |
| 30 public: | |
| 31 typedef base::Callback<void(const Manifest&)> GetManifestCallback; | |
| 32 | |
| 33 explicit ManifestManager(RenderFrame* render_frame); | |
| 34 virtual ~ManifestManager(); | |
| 35 | |
| 36 // Will call the given |callback| with the Manifest associated with the | |
| 37 // RenderFrame if any. Will pass an empty Manifest in case of error. | |
| 38 void GetManifest(const GetManifestCallback& callback); | |
| 39 | |
| 40 // RenderFrameObserver implementation. | |
| 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 42 virtual void DidChangeManifest() OVERRIDE; | |
| 43 | |
| 44 private: | |
| 45 enum ResolveState { | |
| 46 ResolveStateSuccess, | |
| 47 ResolveStateFailure | |
| 48 }; | |
| 49 | |
| 50 // Called when receiving a ManifestManagerMsg_RequestManifest from the browser | |
| 51 // process. | |
| 52 void OnRequestManifest(int request_id); | |
| 53 void OnRequestManifestComplete(int request_id, const Manifest&); | |
| 54 | |
| 55 void DownloadManifest(); | |
|
kenneth.christiansen
2014/09/11 09:33:10
FetchManifest?
mlamouri (slow - plz ping)
2014/09/11 10:30:32
Done.
| |
| 56 void OnManifestFetchComplete(const blink::WebURLResponse& response, | |
|
kenneth.christiansen
2014/09/11 09:33:09
Here Fetch is used, and not Download as above
mlamouri (slow - plz ping)
2014/09/11 10:30:32
Done.
| |
| 57 const std::string& data); | |
| 58 void ResolveCallbacks(ResolveState state); | |
| 59 | |
| 60 scoped_ptr<ManifestFetcher> fetcher_; | |
| 61 | |
| 62 // Whether the RenderFrame may have an associated Manifest. If true, the frame | |
| 63 // may have a manifest, if false, it can't have one. | |
|
kenneth.christiansen
2014/09/11 09:33:10
Maybe a bit more explanation to why it cannot have
mlamouri (slow - plz ping)
2014/09/11 10:30:32
Done.
| |
| 64 bool may_have_manifest_; | |
| 65 | |
| 66 // Whether the current Manifest is dirty. | |
| 67 bool manifest_dirty_; | |
| 68 | |
| 69 // Current Manifest. Might be outdated if manifest_dirty_ is true. | |
| 70 Manifest manifest_; | |
| 71 | |
| 72 std::list<GetManifestCallback> pending_callbacks_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(ManifestManager); | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_MANAGER_H_ | |
| OLD | NEW |