| Index: chrome/browser/printing/print_preview_data_service.cc
|
| diff --git a/chrome/browser/printing/print_preview_data_service.cc b/chrome/browser/printing/print_preview_data_service.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2d27da3b274a7ef3d8f65780f2bc820d113ab9e0
|
| --- /dev/null
|
| +++ b/chrome/browser/printing/print_preview_data_service.cc
|
| @@ -0,0 +1,42 @@
|
| +// 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"
|
| +#include "chrome/browser/ui/webui/print_preview_ui.h"
|
| +
|
| +// static
|
| +PrintPreviewDataService* PrintPreviewDataService::GetInstance() {
|
| + return Singleton<PrintPreviewDataService>::get();
|
| +}
|
| +
|
| +PrintPreviewDataService::PrintPreviewDataService() {
|
| +}
|
| +
|
| +PrintPreviewDataService::~PrintPreviewDataService() {
|
| +}
|
| +
|
| +void PrintPreviewDataService::GetDataEntry(
|
| + PrintPreviewUI* preview_ui, scoped_refptr<RefCountedBytes>* data_bytes) {
|
| + printf("Get Data Entry: %p \n", preview_ui);
|
| + PreviewDataSourceMap::iterator it = data_src_map_.find(preview_ui);
|
| + if (it != data_src_map_.end())
|
| + *data_bytes = it->second.get();
|
| +}
|
| +
|
| +void PrintPreviewDataService::SetDataEntry(
|
| + PrintPreviewUI* preview_ui, const RefCountedBytes* data_bytes) {
|
| + printf("S Data Entry: %p \n", preview_ui);
|
| + RemoveEntry(preview_ui);
|
| + data_src_map_[preview_ui] = const_cast<RefCountedBytes*>(data_bytes);
|
| +}
|
| +
|
| +void PrintPreviewDataService::RemoveEntry(
|
| + PrintPreviewUI* preview_ui) {
|
| + printf("R Data Entry: %p \n", preview_ui);
|
| + PreviewDataSourceMap::iterator it = data_src_map_.find(preview_ui);
|
| + if (it != data_src_map_.end())
|
| + data_src_map_.erase(it);
|
| +}
|
|
|