Chromium Code Reviews| Index: athena/content/content_proxy.h |
| diff --git a/athena/content/content_proxy.h b/athena/content/content_proxy.h |
| index d42c0e1c201e44be7bdc32a0c88f66cf3248eb29..ae81413ee838ea462c64d20e89565a794dac92cd 100644 |
| --- a/athena/content/content_proxy.h |
| +++ b/athena/content/content_proxy.h |
| @@ -6,35 +6,27 @@ |
| #define ATHENA_CONTENT_CONTENT_PROXY_H_ |
| #include "base/macros.h" |
| +#include "base/memory/ref_counted_memory.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "ui/gfx/image/image_skia.h" |
| - |
| -namespace aura { |
| -class Window; |
| -} |
| +#include "base/memory/weak_ptr.h" |
| +#include "ui/gfx/image/image.h" |
| namespace views { |
| -class View; |
| class WebView; |
| } |
| -typedef unsigned int SkColor; |
| - |
| namespace athena { |
| class Activity; |
| -class AppActivity; |
| -class AppActivityProxy; |
| -class WebActivity; |
| +class ProxyImageData; |
| // This object creates and holds proxy content which gets shown instead of the |
| // actual web content, generated from the passed |web_view|. |
| // The created |proxy_content_| will be destroyed with the destruction of this |
| // object. |
| -// Calling EvictContent() will release the rendered content and replaces it with |
| -// a solid color to save memory. |
| -// Calling Reparent() will transfer the |proxy_content_| to an ActivityProxy, |
| -// allowing the destruction of the original activity / content. |
| +// Calling EvictContent() will release the rendered content. |
| +// When ContentGetsDestroyed() gets called, the old view will be made visible |
| +// and then the link to the |web_view_| will get severed. |
| class ContentProxy { |
| public: |
| // Creates the object by creating a sized down |web_view| layer and making it |
| @@ -58,13 +50,11 @@ class ContentProxy { |
| // Get the image of the content. If there is no image known, an empty image |
| // will be returned. |
| - gfx::ImageSkia GetContentImage(); |
| + scoped_ptr<gfx::Image> GetContentImage(); |
|
oshima
2014/09/22 16:10:28
ditto
Mr4D (OOO till 08-26)
2014/09/23 19:07:34
Done.
|
| - // Transfer the owned |proxy_content_| to the |new_parent_window|. |
| - // Once called, the |web_view_| will be made visible again and the connection |
| - // to it will be removed since the old activity might go away. |
| + // The content is about to get destroyed by its creator. |
|
oshima
2014/09/22 16:10:28
Called when the content is about to ...
If this i
Mr4D (OOO till 08-26)
2014/09/23 19:07:34
As mentioned in another parallel CL: I always cons
|
| // Note: This function should only be used by AppActivity. |
| - void Reparent(aura::Window* new_parent_window); |
| + void ContentGetsDestroyed(); |
| private: |
| // Make the original (web)content visible. This call should only be paired |
| @@ -75,40 +65,42 @@ class ContentProxy { |
| // MakeVisible. |
| void HideOriginalContent(); |
| - // Creates proxy content from |web_view_|. If there is no |web_view_|, |
| - // a solid |proxy_content_| with |background_color_| will be created. |
| + // Creates proxy content from |web_view_|. |
| void CreateProxyContent(); |
| - // Creates a solid |proxy_content_| with |background_color_|. |
| - void CreateSolidProxyContent(); |
| + // Creates an image from the current content. |
| + bool GetContentAsImage(); |
|
oshima
2014/09/22 16:10:28
CreateContentImage ?
Mr4D (OOO till 08-26)
2014/09/23 19:07:34
Done.
|
| - // Show the |proxy_content_| in the current |window_|. |
| - void ShowProxyContent(); |
| + // Called once the content was read back. |
| + void ContentReadBackAsImage(bool success, const SkBitmap& bitmap); |
|
oshima
2014/09/22 16:10:28
OnContentImage{Read/Created/..}?
Mr4D (OOO till 08-26)
2014/09/23 19:07:34
Done.
|
| - // Removes the |proxy_content_| from the window again. |
| - void HideProxyContent(); |
| + // Called once the image content has been converted to PNG. |
| + void OnContentImageEncodeComplete(scoped_refptr<ProxyImageData> image); |
| - // The web view which is associated with this object. It will be NULL after |
| - // the object got called with Reparent(), since the Activity which owns it |
| - // will be destroyed shortly after. |
| + // The web view which is associated with this object. It will be shown when |
| + // ContentGetsDestroyed() gets called and then set to NULL. |
|
oshima
2014/09/22 16:10:28
can you document ownership?
Mr4D (OOO till 08-26)
2014/09/23 19:07:34
Done.
|
| views::WebView* web_view_; |
| - // The window which shows our |proxy_content_|, |
| - aura::Window* window_; |
| + // While we are doing our PNG encode, we keep the read back image to have |
| + // something which we can pass back to the overview mode. (It would make no |
| + // sense to the user to see that more recent windows get painted later than |
| + // older ones). |
| + gfx::Image image_; |
| - // The background color to use when evicted. |
| - SkColor background_color_; |
| + // True if the content is visible. |
| + bool content_visible_; |
| - // If we have an image (e.g. from session restore) it is stored here. |
| - gfx::ImageSkia image_; |
| - |
| - // True if the content is loaded. |
| + // True if the content is loaded and needs a re-layout when it gets shown |
| + // again. |
| bool content_loaded_; |
| - // The content representation which which will be presented to the user. It |
| - // will either contain a shrunken down image of the |web_view| content or a |
| - // solid |background_color_|. |
| - scoped_ptr<views::View> proxy_content_; |
| + // The PNG image data. |
| + scoped_refptr<base::RefCountedBytes> png_data_; |
| + |
| + // Creating an encoded image from the content will be asynchronous. Use a |
| + // weakptr for the callback to make sure that the read back / encoding image |
| + // completion callback does not trigger on a destroyed ContentProxy. |
| + base::WeakPtrFactory<ContentProxy> proxy_content_to_image_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ContentProxy); |
| }; |