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