Chromium Code Reviews| Index: ios/chrome/browser/dom_distiller/favicon_web_state_dispatcher_impl.h |
| diff --git a/ios/chrome/browser/dom_distiller/favicon_web_state_dispatcher_impl.h b/ios/chrome/browser/dom_distiller/favicon_web_state_dispatcher_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92126921927486713ab02c7d259d021b28393f6e |
| --- /dev/null |
| +++ b/ios/chrome/browser/dom_distiller/favicon_web_state_dispatcher_impl.h |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef IOS_CHROME_BROWSER_DOM_DISTILLER_FAVICON_WEB_STATE_DISPATCHER_IMPL_H_ |
| +#define IOS_CHROME_BROWSER_DOM_DISTILLER_FAVICON_WEB_STATE_DISPATCHER_IMPL_H_ |
| + |
| +#include <map> |
| +#include <memory> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/dom_distiller/ios/favicon_web_state_dispatcher.h" |
| + |
| +namespace web { |
| +class BrowserState; |
| +} |
| + |
| +namespace dom_distiller { |
| + |
| +// Implementation of the FaviconWebStateDispatcher. |
| +class FaviconWebStateDispatcherImpl : public FaviconWebStateDispatcher { |
| + public: |
| + // Constructor with default delay for keeping the WebStates alive. |
| + explicit FaviconWebStateDispatcherImpl(web::BrowserState* browser_state); |
| + // Constructor for keeping the WebStates alive for |keep_alive_time|. |
|
sdefresne
2016/12/20 15:41:00
Can you add as comment that -1 means to use the de
gambard
2016/12/20 17:11:42
Done.
|
| + explicit FaviconWebStateDispatcherImpl(web::BrowserState* browser_state, |
|
sdefresne
2016/12/20 15:41:00
Remove explicit here, it is only for constructor t
gambard
2016/12/20 17:11:42
Done.
|
| + int keep_alive_time); |
| + ~FaviconWebStateDispatcherImpl() override; |
| + |
| + // FaviconWebStateDispatcher implementation. |
| + web::WebState* RequestWebState() override; |
| + void ReturnWebState(web::WebState* web_state) override; |
| + |
| + private: |
| + web::BrowserState* browser_state_; |
| + // Map of the WebStates currently alive. |
| + std::map<web::WebState*, std::unique_ptr<web::WebState>> web_states_; |
|
sdefresne
2016/12/20 15:41:00
I think it would be simpler to use a std::vector<s
gambard
2016/12/20 17:11:42
Done.
|
| + // Time during which the WebState will be kept alive after being returned. |
| + int keep_alive_time_; |
| + base::WeakPtrFactory<FaviconWebStateDispatcherImpl> weak_ptr_factory_; |
| +}; |
| + |
| +} // namespace dom_distiller |
| + |
| +#endif // IOS_CHROME_BROWSER_DOM_DISTILLER_FAVICON_WEB_STATE_DISPATCHER_IMPL_H_ |