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

Side by Side Diff: athena/content/content_proxy.h

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « athena/content/content_activity_factory.cc ('k') | athena/content/content_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 ATHENA_CONTENT_CONTENT_PROXY_H_
6 #define ATHENA_CONTENT_CONTENT_PROXY_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/readback_types.h"
13 #include "ui/gfx/image/image_skia.h"
14
15 namespace views {
16 class WebView;
17 }
18
19 namespace athena {
20
21 class ProxyImageData;
22
23 // This object creates and holds proxy content which gets shown instead of the
24 // actual web content, generated from the passed |web_view|.
25 // The created |proxy_content_| will be destroyed with the destruction of this
26 // object.
27 // Calling EvictContent() will release the rendered content.
28 // When ContentGetsDestroyed() gets called, the old view will be made visible
29 // and then the link to the |web_view_| will get severed.
30 class ContentProxy {
31 public:
32 // Creates the object by creating a sized down |web_view| layer.
33 explicit ContentProxy(views::WebView* web_view);
34 // TODO(skuhne): Add a function to create this object from a passed PNG, so
35 // that we can create it from a session restore.
36
37 // With the destruction of the object, the layer should get destroyed and the
38 // content should become visible again.
39 virtual ~ContentProxy();
40
41 // Called when the content will get unloaded.
42 void ContentWillUnload();
43
44 // Can be called to save resources by creating a layer with a solid color
45 // instead of creating a content image layer.
46 // Note: Currently the GPU does create a full size texture and fills it with
47 // the given color - so there isn't really memory savings yet.
48 void EvictContent();
49
50 // Get the image of the content. If there is no image known, an empty image
51 // will be returned.
52 gfx::ImageSkia GetContentImage();
53
54 // The content is about to get destroyed by its creator.
55 // Note: This function should only be used by AppActivity.
56 void OnPreContentDestroyed();
57
58 private:
59 // Make the original (web)content visible. This call should only be paired
60 // with HideOriginalContent.
61 void ShowOriginalContent();
62
63 // Make the content invisible. This call should only be paired with
64 // MakeVisible.
65 void HideOriginalContent();
66
67 // Creates proxy content from |web_view_|.
68 void CreateProxyContent();
69
70 // Creates an image from the current content.
71 bool CreateContentImage();
72
73 // Called once the content was read back.
74 void OnContentImageRead(const SkBitmap& bitmap,
75 content::ReadbackResponse response);
76
77 // Called once the image content has been converted to PNG.
78 void OnContentImageEncodeComplete(scoped_refptr<ProxyImageData> image);
79
80 // The web view which was passed on creation and is associated with this
81 // object. It will be shown when OnPreContentDestroyed() gets called and then
82 // set to nullptr. The ownership remains with the creator.
83 views::WebView* web_view_;
84
85 // While we are doing our PNG encode, we keep the read back image to have
86 // something which we can pass back to the overview mode. (It would make no
87 // sense to the user to see that more recent windows get painted later than
88 // older ones).
89 gfx::ImageSkia raw_image_;
90
91 // True if the content is visible.
92 bool content_visible_;
93
94 // True if the content is loaded and needs a re-layout when it gets shown
95 // again.
96 bool content_loaded_;
97
98 // True if a content creation was kicked off once. This ensures that the
99 // function is never called twice.
100 bool content_creation_called_;
101
102 // The PNG image data.
103 scoped_refptr<base::RefCountedBytes> png_data_;
104
105 // Creating an encoded image from the content will be asynchronous. Use a
106 // weakptr for the callback to make sure that the read back / encoding image
107 // completion callback does not trigger on a destroyed ContentProxy.
108 base::WeakPtrFactory<ContentProxy> proxy_content_to_image_factory_;
109
110 DISALLOW_COPY_AND_ASSIGN(ContentProxy);
111 };
112
113 } // namespace athena
114
115 #endif // ATHENA_CONTENT_CONTENT_PROXY_H_
OLDNEW
« no previous file with comments | « athena/content/content_activity_factory.cc ('k') | athena/content/content_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698