OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_CORE_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_CORE_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/appcache_interfaces.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class AppCacheNavigationHandle; |
| 18 class AppCacheHost; |
| 19 class AppCacheServiceImpl; |
| 20 class ChromeAppCacheService; |
| 21 |
| 22 // PlzNavigate |
| 23 // This class is used to manage the lifetime of AppCacheHosts |
| 24 // created during navigations. This class is created on the UI thread, but |
| 25 // should only be accessed from the IO thread afterwards. It is the IO thread |
| 26 // pendant of AppCacheNavigationHandle. See the |
| 27 // AppCacheNavigationHandle header for more details about the lifetime of |
| 28 // both classes. |
| 29 class AppCacheNavigationHandleCore : public AppCacheFrontend { |
| 30 public: |
| 31 AppCacheNavigationHandleCore( |
| 32 base::WeakPtr<AppCacheNavigationHandle> ui_handle, |
| 33 ChromeAppCacheService* appcache_service, |
| 34 int appcache_host_id); |
| 35 ~AppCacheNavigationHandleCore() override; |
| 36 |
| 37 // Returns the raw AppCacheHost pointer. Ownership remains with this class. |
| 38 AppCacheHost* host() { return precreated_host_.get(); } |
| 39 |
| 40 // Initializes this instance. Should be called on the IO thread. |
| 41 void Initialize(); |
| 42 |
| 43 // Returns the precreated AppCacheHost pointer. Ownership of the host is |
| 44 // released here. |
| 45 static std::unique_ptr<AppCacheHost> GetPrecreatedHost(int host_id); |
| 46 |
| 47 AppCacheServiceImpl* GetAppCacheService(); |
| 48 |
| 49 protected: |
| 50 // AppCacheFrontend methods |
| 51 // We don't expect calls on the AppCacheFrontend methods while the |
| 52 // AppCacheHost is not registered with the AppCacheBackend. |
| 53 void OnCacheSelected(int host_id, const AppCacheInfo& info) override; |
| 54 void OnStatusChanged(const std::vector<int>& host_ids, |
| 55 AppCacheStatus status) override; |
| 56 void OnEventRaised(const std::vector<int>& host_ids, |
| 57 AppCacheEventID event_id) override; |
| 58 void OnProgressEventRaised(const std::vector<int>& host_ids, |
| 59 const GURL& url, |
| 60 int num_total, |
| 61 int num_complete) override; |
| 62 void OnErrorEventRaised(const std::vector<int>& host_ids, |
| 63 const AppCacheErrorDetails& details) override; |
| 64 void OnLogMessage(int host_id, |
| 65 AppCacheLogLevel log_level, |
| 66 const std::string& message) override; |
| 67 void OnContentBlocked(int host_id, const GURL& manifest_url) override; |
| 68 |
| 69 private: |
| 70 std::unique_ptr<AppCacheHost> precreated_host_; |
| 71 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 72 int appcache_host_id_; |
| 73 base::WeakPtr<AppCacheNavigationHandle> ui_handle_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(AppCacheNavigationHandleCore); |
| 76 }; |
| 77 |
| 78 } // namespace content |
| 79 |
| 80 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_CORE_H_ |
OLD | NEW |