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

Unified Diff: chrome/browser/android/thumbnail/thumbnail_impl.h

Issue 262543002: android: add ThumbnailCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@codec
Patch Set: separate into multiple files Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/thumbnail/thumbnail_impl.h
diff --git a/chrome/browser/android/thumbnail/thumbnail_impl.h b/chrome/browser/android/thumbnail/thumbnail_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..c550337a31c84e5bf4478aafc7a68b86159b9bbc
--- /dev/null
+++ b/chrome/browser/android/thumbnail/thumbnail_impl.h
@@ -0,0 +1,91 @@
+// Copyright 2014 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 CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_IMPL_H_
+#define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_IMPL_H_
+
+#include "chrome/browser/android/thumbnail/thumbnail.h"
+#include "content/public/browser/android/ui_resource_client_android.h"
+#include "skia/ext/refptr.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/geometry/size_f.h"
+
+class ThumbnailCache;
+
+namespace base {
+class File;
+}
+
+namespace content {
+class UIResourceProvider;
+}
+
+class ThumbnailImpl;
+class ThumbnailImplManager {
+ public:
+ virtual void InvalidateCachedThumbnail(
+ scoped_refptr<ThumbnailImpl> thumbnail) = 0;
+ virtual ~ThumbnailImplManager() {}
+};
+
+class ThumbnailImpl : public Thumbnail,
+ public content::UIResourceClientAndroid {
+ public:
+ ThumbnailImpl(TabId tab_id,
+ const SkBitmap& bitmap,
+ float scale,
+ ThumbnailImplManager* thumbnail_impl_manager,
+ content::UIResourceProvider* ui_resource_provider);
+ bool IsValid() const;
+
+ // Thumbnail implementation.
+ virtual gfx::Size GetScaledContentSize() const OVERRIDE;
+ virtual gfx::SizeF GetScaledDataSize() const OVERRIDE;
+ virtual cc::UIResourceId ui_resource_id() const OVERRIDE {
+ return ui_resource_id_;
+ }
+ virtual TabId tab_id() const OVERRIDE { return tab_id_; }
+
+ static void Compress(scoped_refptr<ThumbnailImpl> in_thumbnail,
+ scoped_refptr<ThumbnailImpl> out_thumbnail);
+ static bool WriteToFile(scoped_refptr<ThumbnailImpl> thumbnail,
+ base::File& file);
+ static bool ReadFromFile(base::File& file,
+ scoped_refptr<ThumbnailImpl> thumbnail);
+
+ scoped_refptr<ThumbnailImpl> PassDataToNewThumbnail();
+
+ // content::UIResourceClient implementation.
+ virtual cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid,
+ bool resource_lost) OVERRIDE;
+
+ // content::UIResourceClientAndroid implementation.
+ virtual void UIResourceIsInvalid() OVERRIDE;
+
+ protected:
+ virtual ~ThumbnailImpl();
+
+ private:
+ void CleanupUIResource();
+ void BuildUIResource();
+ void SetRawData(SkBitmap bitmap, float scale);
+ void SetCompressedData(skia::RefPtr<SkPixelRef> compressed_data,
+ float scale,
+ const gfx::Size& content_size);
+ TabId tab_id_;
+ cc::UIResourceId ui_resource_id_;
+ SkBitmap raw_data_;
+ skia::RefPtr<SkPixelRef> compressed_data_;
+ float scale_;
+ gfx::Size data_size_;
+ gfx::Size content_size_;
+
+ ThumbnailImplManager* thumbnail_impl_manager_;
+ content::UIResourceProvider* ui_resource_provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThumbnailImpl);
+};
+
+#endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698