OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_THUMBNAILS_THUMBNAILING_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAILING_CONTEXT_H_ |
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAILING_CONTEXT_H_ | 6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAILING_CONTEXT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "chrome/browser/thumbnails/thumbnail_service.h" | 10 #include "chrome/browser/thumbnails/thumbnail_service.h" |
11 #include "components/history/core/common/thumbnail_score.h" | 11 #include "components/history/core/common/thumbnail_score.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_observer.h" | |
13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
14 | 15 |
15 namespace thumbnails { | 16 namespace thumbnails { |
16 | 17 |
17 // The result of clipping. This can be used to determine if the | 18 // The result of clipping. This can be used to determine if the |
18 // generated thumbnail is good or not. | 19 // generated thumbnail is good or not. |
19 enum ClipResult { | 20 enum ClipResult { |
20 // Clipping is not done yet. | 21 // Clipping is not done yet. |
21 CLIP_RESULT_UNPROCESSED, | 22 CLIP_RESULT_UNPROCESSED, |
22 // The source image is smaller. | 23 // The source image is smaller. |
23 CLIP_RESULT_SOURCE_IS_SMALLER, | 24 CLIP_RESULT_SOURCE_IS_SMALLER, |
24 // Wider than tall by twice or more, clip horizontally. | 25 // Wider than tall by twice or more, clip horizontally. |
25 CLIP_RESULT_MUCH_WIDER_THAN_TALL, | 26 CLIP_RESULT_MUCH_WIDER_THAN_TALL, |
26 // Wider than tall, clip horizontally. | 27 // Wider than tall, clip horizontally. |
27 CLIP_RESULT_WIDER_THAN_TALL, | 28 CLIP_RESULT_WIDER_THAN_TALL, |
28 // Taller than wide, clip vertically. | 29 // Taller than wide, clip vertically. |
29 CLIP_RESULT_TALLER_THAN_WIDE, | 30 CLIP_RESULT_TALLER_THAN_WIDE, |
30 // The source and destination aspect ratios are identical. | 31 // The source and destination aspect ratios are identical. |
31 CLIP_RESULT_NOT_CLIPPED, | 32 CLIP_RESULT_NOT_CLIPPED, |
32 // The source and destination are identical. | 33 // The source and destination are identical. |
33 CLIP_RESULT_SOURCE_SAME_AS_TARGET, | 34 CLIP_RESULT_SOURCE_SAME_AS_TARGET, |
34 }; | 35 }; |
35 | 36 |
36 // Holds the information needed for processing a thumbnail. | 37 // Holds the information needed for processing a thumbnail. |
37 struct ThumbnailingContext : base::RefCountedThreadSafe<ThumbnailingContext> { | 38 struct ThumbnailingContext |
Lei Zhang
2015/10/26 23:31:35
This is looking a bit more complicated now. When i
| |
39 : base::RefCountedThreadSafe<ThumbnailingContext>, | |
40 content::WebContentsObserver { | |
38 ThumbnailingContext(content::WebContents* web_contents, | 41 ThumbnailingContext(content::WebContents* web_contents, |
39 ThumbnailService* receiving_service, | 42 ThumbnailService* receiving_service, |
40 bool load_interrupted); | 43 bool load_interrupted); |
41 | 44 |
42 // Create an instance for use with unit tests. | 45 // Create an instance for use with unit tests. |
43 static ThumbnailingContext* CreateThumbnailingContextForTest() { | 46 static ThumbnailingContext* CreateThumbnailingContextForTest() { |
44 return new ThumbnailingContext(); | 47 return new ThumbnailingContext(); |
45 } | 48 } |
46 | 49 |
47 scoped_refptr<ThumbnailService> service; | 50 scoped_refptr<ThumbnailService> service; |
48 GURL url; | 51 GURL url; |
49 ClipResult clip_result; | 52 ClipResult clip_result; |
50 gfx::Size requested_copy_size; | 53 gfx::Size requested_copy_size; |
51 ThumbnailScore score; | 54 ThumbnailScore score; |
52 | 55 |
53 private: | 56 private: |
54 ThumbnailingContext(); | 57 ThumbnailingContext(); |
Lei Zhang
2015/10/26 23:31:35
Maybe just DISALLOW_IMPLICIT_CONSTRUCTORS?
| |
55 ~ThumbnailingContext(); | 58 ~ThumbnailingContext(); |
56 | 59 |
57 friend class base::RefCountedThreadSafe<ThumbnailingContext>; | 60 friend class base::RefCountedThreadSafe<ThumbnailingContext>; |
58 }; | 61 }; |
59 | 62 |
60 } // namespace thumbnails | 63 } // namespace thumbnails |
61 | 64 |
62 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAILING_CONTEXT_H_ | 65 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAILING_CONTEXT_H_ |
OLD | NEW |