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

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail.h

Issue 1371523003: Android: Don't destroy LayerTreeHost when Surface goes away (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_
6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_ 6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "cc/resources/ui_resource_bitmap.h" 10 #include "cc/resources/ui_resource_bitmap.h"
11 #include "cc/resources/ui_resource_client.h" 11 #include "cc/resources/ui_resource_client.h"
12 #include "ui/android/resources/ui_resource_client_android.h"
13 #include "ui/gfx/geometry/size_f.h" 12 #include "ui/gfx/geometry/size_f.h"
14 13
15 namespace base { 14 namespace base {
16 class Time; 15 class Time;
17 } 16 }
18 17
19 namespace gfx { 18 namespace gfx {
20 class Size; 19 class Size;
21 } 20 }
22 21
23 namespace ui { 22 namespace ui {
24 class UIResourceProvider; 23 class UIResourceProvider;
25 } 24 }
26 25
27 typedef int TabId; 26 typedef int TabId;
28 27
29 class Thumbnail; 28 class Thumbnail;
30 29
31 class ThumbnailDelegate { 30 class ThumbnailDelegate {
32 public: 31 public:
33 virtual void InvalidateCachedThumbnail(Thumbnail* thumbnail) = 0; 32 virtual void InvalidateCachedThumbnail(Thumbnail* thumbnail) = 0;
34 virtual ~ThumbnailDelegate() {} 33 virtual ~ThumbnailDelegate() {}
35 }; 34 };
36 35
37 class Thumbnail : public ui::UIResourceClientAndroid { 36 class Thumbnail : public cc::UIResourceClient {
38 public: 37 public:
39 static scoped_ptr<Thumbnail> Create( 38 static scoped_ptr<Thumbnail> Create(
40 TabId tab_id, 39 TabId tab_id,
41 const base::Time& time_stamp, 40 const base::Time& time_stamp,
42 float scale, 41 float scale,
43 ui::UIResourceProvider* ui_resource_provider, 42 ui::UIResourceProvider* ui_resource_provider,
44 ThumbnailDelegate* thumbnail_delegate); 43 ThumbnailDelegate* thumbnail_delegate);
45 ~Thumbnail() override; 44 ~Thumbnail() override;
46 45
47 TabId tab_id() const { return tab_id_; } 46 TabId tab_id() const { return tab_id_; }
48 base::Time time_stamp() const { return time_stamp_; } 47 base::Time time_stamp() const { return time_stamp_; }
49 float scale() const { return scale_; } 48 float scale() const { return scale_; }
50 cc::UIResourceId ui_resource_id() const { return ui_resource_id_; } 49 cc::UIResourceId ui_resource_id() const { return ui_resource_id_; }
51 const gfx::SizeF& scaled_content_size() const { return scaled_content_size_; } 50 const gfx::SizeF& scaled_content_size() const { return scaled_content_size_; }
52 const gfx::SizeF& scaled_data_size() const { return scaled_data_size_; } 51 const gfx::SizeF& scaled_data_size() const { return scaled_data_size_; }
53 52
54 void SetBitmap(const SkBitmap& bitmap); 53 void SetBitmap(const SkBitmap& bitmap);
55 void SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap, 54 void SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap,
56 const gfx::Size& content_size); 55 const gfx::Size& content_size);
57 void CreateUIResource(); 56 void CreateUIResource();
58 57
59 // content::UIResourceClient implementation. 58 // cc::UIResourceClient implementation.
60 cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid, 59 cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid,
61 bool resource_lost) override; 60 bool resource_lost) override;
62 61
63 // ui::UIResourceClientAndroid implementation. 62 private:
64 void UIResourceIsInvalid() override;
65
66 protected:
67 Thumbnail(TabId tab_id, 63 Thumbnail(TabId tab_id,
68 const base::Time& time_stamp, 64 const base::Time& time_stamp,
69 float scale, 65 float scale,
70 ui::UIResourceProvider* ui_resource_provider, 66 ui::UIResourceProvider* ui_resource_provider,
71 ThumbnailDelegate* thumbnail_delegate); 67 ThumbnailDelegate* thumbnail_delegate);
72 68
73 void ClearUIResourceId(); 69 void ClearUIResourceId();
70 void DoInvalidate();
74 71
75 TabId tab_id_; 72 TabId tab_id_;
76 base::Time time_stamp_; 73 base::Time time_stamp_;
77 float scale_; 74 float scale_;
78 75
79 gfx::SizeF scaled_content_size_; 76 gfx::SizeF scaled_content_size_;
80 gfx::SizeF scaled_data_size_; 77 gfx::SizeF scaled_data_size_;
81 78
82 cc::UIResourceBitmap bitmap_; 79 cc::UIResourceBitmap bitmap_;
83 cc::UIResourceId ui_resource_id_; 80 cc::UIResourceId ui_resource_id_;
84 81
85 bool retrieved_; 82 bool retrieved_;
86 83
87 ui::UIResourceProvider* ui_resource_provider_; 84 ui::UIResourceProvider* ui_resource_provider_;
88 ThumbnailDelegate* thumbnail_delegate_; 85 ThumbnailDelegate* thumbnail_delegate_;
89 86
87 base::WeakPtrFactory<Thumbnail> weak_factory_;
90 DISALLOW_COPY_AND_ASSIGN(Thumbnail); 88 DISALLOW_COPY_AND_ASSIGN(Thumbnail);
91 }; 89 };
92 90
93 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_ 91 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/compositor/tab_content_manager.cc ('k') | chrome/browser/android/thumbnail/thumbnail.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698