OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/printing/print_preview_data_service.h" |
| 6 |
| 7 #include "base/memory/singleton.h" |
| 8 |
| 9 // static |
| 10 PrintPreviewDataService* PrintPreviewDataService::GetInstance() { |
| 11 return Singleton<PrintPreviewDataService>::get(); |
| 12 } |
| 13 |
| 14 PrintPreviewDataService::PrintPreviewDataService() { |
| 15 } |
| 16 |
| 17 PrintPreviewDataService::~PrintPreviewDataService() { |
| 18 } |
| 19 |
| 20 void PrintPreviewDataService::GetDataEntry( |
| 21 const std::string& preview_ui_addr_str, |
| 22 scoped_refptr<RefCountedBytes>* data_bytes) { |
| 23 PreviewDataSourceMap::iterator it = data_src_map_.find(preview_ui_addr_str); |
| 24 if (it != data_src_map_.end()) |
| 25 *data_bytes = it->second.get(); |
| 26 } |
| 27 |
| 28 void PrintPreviewDataService::SetDataEntry( |
| 29 const std::string& preview_ui_addr_str, const RefCountedBytes* data_bytes) { |
| 30 RemoveEntry(preview_ui_addr_str); |
| 31 data_src_map_[preview_ui_addr_str] = const_cast<RefCountedBytes*>(data_bytes); |
| 32 } |
| 33 |
| 34 void PrintPreviewDataService::RemoveEntry( |
| 35 const std::string& preview_ui_addr_str) { |
| 36 PreviewDataSourceMap::iterator it = data_src_map_.find(preview_ui_addr_str); |
| 37 if (it != data_src_map_.end()) |
| 38 data_src_map_.erase(it); |
| 39 } |
OLD | NEW |