Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 ScreenshotDataPtr GetCachedScreenshot(const std::string& path); |
| 30 | 35 |
| 31 private: | 36 private: |
| 32 virtual ~ScreenshotSource(); | 37 virtual ~ScreenshotSource(); |
| 33 | 38 |
| 34 std::vector<unsigned char> current_screenshot_; | 39 // Sends the screenshot data to the requestor while caching it locally to the |
| 40 // class instance, indexed by path. | |
| 41 void CacheAndSendScreenshot(const std::string& path, | |
| 42 int request_id, | |
| 43 ScreenshotDataPtr bytes); | |
| 44 void SendScreenshot(const std::string& path, int request_id); | |
| 45 #if defined(OS_CHROMEOS) | |
| 46 void SendSavedScreenshot(const std::string& filename, int request_id); | |
|
Daniel Erat
2011/08/22 16:42:02
headers should have comments describing what funct
rkc
2011/08/23 10:25:20
Done.
| |
| 47 #endif | |
| 48 | |
| 49 ScreenshotDataPtr current_screenshot_; | |
| 50 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; | |
|
Daniel Erat
2011/08/22 16:42:02
add a comment here describing what you're using as
rkc
2011/08/23 10:25:20
Done.
| |
| 35 | 51 |
| 36 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); | 52 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); |
| 37 }; | 53 }; |
| 38 | 54 |
| 39 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 55 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ |
| OLD | NEW |