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

Side by Side Diff: core/fpdfapi/cpdf_modulemgr.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « no previous file | core/fpdfapi/edit/fpdf_edit_create.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/cpdf_modulemgr.h" 7 #include "core/fpdfapi/cpdf_modulemgr.h"
8 8
9 #include "core/fpdfapi/page/cpdf_pagemodule.h" 9 #include "core/fpdfapi/page/cpdf_pagemodule.h"
10 #include "core/fxcodec/fx_codec.h" 10 #include "core/fxcodec/fx_codec.h"
11 #include "third_party/base/ptr_util.h"
11 12
12 namespace { 13 namespace {
13 14
14 CPDF_ModuleMgr* g_pDefaultMgr = nullptr; 15 CPDF_ModuleMgr* g_pDefaultMgr = nullptr;
15 16
16 } // namespace 17 } // namespace
17 18
18 // static 19 // static
19 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() { 20 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() {
20 if (!g_pDefaultMgr) 21 if (!g_pDefaultMgr)
21 g_pDefaultMgr = new CPDF_ModuleMgr; 22 g_pDefaultMgr = new CPDF_ModuleMgr;
22 return g_pDefaultMgr; 23 return g_pDefaultMgr;
23 } 24 }
24 25
25 // static 26 // static
26 void CPDF_ModuleMgr::Destroy() { 27 void CPDF_ModuleMgr::Destroy() {
27 delete g_pDefaultMgr; 28 delete g_pDefaultMgr;
28 g_pDefaultMgr = nullptr; 29 g_pDefaultMgr = nullptr;
29 } 30 }
30 31
31 CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {} 32 CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}
32 33
33 CPDF_ModuleMgr::~CPDF_ModuleMgr() {} 34 CPDF_ModuleMgr::~CPDF_ModuleMgr() {}
34 35
35 void CPDF_ModuleMgr::InitPageModule() { 36 void CPDF_ModuleMgr::InitPageModule() {
36 m_pPageModule.reset(new CPDF_PageModule); 37 m_pPageModule = pdfium::MakeUnique<CPDF_PageModule>();
37 } 38 }
38 39
39 CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() { 40 CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
40 return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr; 41 return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr;
41 } 42 }
42 43
43 CCodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() { 44 CCodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() {
44 return m_pCodecModule ? m_pCodecModule->GetJpegModule() : nullptr; 45 return m_pCodecModule ? m_pCodecModule->GetJpegModule() : nullptr;
45 } 46 }
46 47
47 CCodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() { 48 CCodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() {
48 return m_pCodecModule ? m_pCodecModule->GetJpxModule() : nullptr; 49 return m_pCodecModule ? m_pCodecModule->GetJpxModule() : nullptr;
49 } 50 }
50 51
51 CCodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() { 52 CCodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() {
52 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : nullptr; 53 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : nullptr;
53 } 54 }
54 55
55 CCodec_IccModule* CPDF_ModuleMgr::GetIccModule() { 56 CCodec_IccModule* CPDF_ModuleMgr::GetIccModule() {
56 return m_pCodecModule ? m_pCodecModule->GetIccModule() : nullptr; 57 return m_pCodecModule ? m_pCodecModule->GetIccModule() : nullptr;
57 } 58 }
58 59
59 CCodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() { 60 CCodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() {
60 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : nullptr; 61 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : nullptr;
61 } 62 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/edit/fpdf_edit_create.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698