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

Side by Side Diff: chrome/browser/ui/webui/screenshot_source.h

Issue 7635017: Fix saved screenshots for feedback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments incorporated. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_UI_WEBUI_SCREENSHOT_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
13 15
16 typedef std::vector<unsigned char> ScreenshotData;
17 typedef linked_ptr<ScreenshotData> ScreenshotDataPtr;
18
14 // ScreenshotSource is the data source that serves screenshots (saved 19 // ScreenshotSource is the data source that serves screenshots (saved
15 // or current) to the bug report html ui 20 // or current) to the bug report html ui
16 class ScreenshotSource : public ChromeURLDataManager::DataSource { 21 class ScreenshotSource : public ChromeURLDataManager::DataSource {
17 public: 22 public:
18 explicit ScreenshotSource( 23 explicit ScreenshotSource(
19 std::vector<unsigned char>* current_screenshot); 24 std::vector<unsigned char>* current_screenshot);
20 25
21 // Called when the network layer has requested a resource underneath 26 // Called when the network layer has requested a resource underneath
22 // the path we registered. 27 // the path we registered.
23 virtual void StartDataRequest(const std::string& path, 28 virtual void StartDataRequest(const std::string& path,
24 bool is_incognito, 29 bool is_incognito,
25 int request_id); 30 int request_id);
26 31
27 virtual std::string GetMimeType(const std::string&) const; 32 virtual std::string GetMimeType(const std::string&) const;
28 33
29 std::vector<unsigned char> GetScreenshot(const std::string& path); 34 // Get the screenshot specified by the given relative path that we've cached
Daniel Erat 2011/08/23 16:58:37 this is confusing to me. the comment says "relati
rkc 2011/08/25 13:09:33 I've redone all the 'path' parameter names in both
35 // from a previous request to the screenshots source
Daniel Erat 2011/08/23 16:58:37 nit: add period at end of sentence
rkc 2011/08/25 13:09:33 Done.
36 // Note: Query string will be stripped from the full_path
Daniel Erat 2011/08/23 16:58:37 nit: add period
rkc 2011/08/25 13:09:33 Done.
37 ScreenshotDataPtr GetCachedScreenshot(const std::string& full_path);
30 38
31 private: 39 private:
32 virtual ~ScreenshotSource(); 40 virtual ~ScreenshotSource();
33 41
34 std::vector<unsigned char> current_screenshot_; 42 // Sends the screenshot data to the requestor while caching it locally to the
43 // class instance, indexed by path.
44 void CacheAndSendScreenshot(const std::string& path,
45 int request_id,
46 ScreenshotDataPtr bytes);
47 // Send the screenshot specified by the given relative path (includes filename
48 // in case of a saved screenshot) to the requestor
Daniel Erat 2011/08/23 16:58:37 nit: add period
rkc 2011/08/25 13:09:33 Done.
49 void SendScreenshot(const std::string& path, int request_id);
50 #if defined(OS_CHROMEOS)
51 // Send a saved screenshot specified by the given filename to the requestor
52 void SendSavedScreenshot(const std::string& filename, int request_id);
Daniel Erat 2011/08/23 16:58:37 why do these methods still all have subtly differe
rkc 2011/08/25 13:09:33 Changed the names and comments to make sense all t
53 #endif
54
55 // Pointer to the screenshot data for the current screenshot
56 ScreenshotDataPtr current_screenshot_;
Daniel Erat 2011/08/23 16:58:37 nit: add blank line after this one
rkc 2011/08/25 13:09:33 Done.
57 // Key: Relative path to the screenshot (including filename)
58 // Value: Pointer to the screenshot data associated with the path
59 std::map<std::string, ScreenshotDataPtr> cached_screenshots_;
35 60
36 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); 61 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource);
37 }; 62 };
38 63
39 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ 64 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698