Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/plugin/PluginAppNamespaceClient.cpp

Issue 5032147387678720: NoIssue - Refactor HTTP and HTTPS namespaces registration
Left Patch Set: Created April 13, 2015, 3:14 a.m.
Right Patch Set: Fix the renaming patchset Created April 24, 2015, 11:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "PluginStdAfx.h"
19
20 #include "PluginAppNamespaceClient.h"
21 #include "PluginClient.h"
22 #include "PluginWbPassThrough.h"
23
24
25 typedef PassthroughAPP::CMetaFactory<PassthroughAPP::CComClassFactoryProtocol,WB Passthru> MetaFactory;
Eric 2015/05/16 21:00:48 This definition could go in an anonymous namespace
26
27
28 CPluginAppNamespaceClient::CPluginAppNamespaceClient() : m_spCFHTTP(NULL), m_sp CFHTTPS(NULL)
29 {
30 // Should only be called once
31 // We register mime filters here
32 // Register asynchronous protocol
33 CComPtr<IInternetSession> spSession;
Eric 2015/05/16 21:00:48 We're also calling 'CoInternetGetSession' in the d
34 HRESULT hr = ::CoInternetGetSession(0, &spSession, 0);
35 if (FAILED(hr) || !spSession)
36 {
37 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_GET_INTERNET_ SESSION, "MimeClient::CoInternetGetSession failed");
38 return;
39 }
40
41 hr = MetaFactory::CreateInstance(CLSID_HttpProtocol, &m_spCFHTTP);
Eric 2015/05/16 21:00:48 The invocation of 'CreateInstance' starts a memory
42 if (FAILED(hr) || !m_spCFHTTP)
43 {
44 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_CREATE_HTTP_I NSTANCE, "MimeClient::CreateInstance failed");
45 return;
46 }
47
48 hr = spSession->RegisterNameSpace(m_spCFHTTP, CLSID_HttpProtocol, L"http", 0, 0, 0);
49 if (FAILED(hr))
50 {
51 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_REGISTER_HTTP _NAMESPACE, "MimeClient::RegisterNameSpace failed");
52 return;
53 }
54
55 hr = MetaFactory::CreateInstance(CLSID_HttpSProtocol, &m_spCFHTTPS);
56 if (FAILED(hr) || !m_spCFHTTPS)
57 {
58 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_CREATE_HTTPS_ INSTANCE, "MimeClient::CreateInstance failed");
59 return;
Eric 2015/05/16 21:00:48 If the "http" handler registers correctly, but thi
60 }
61
62 hr = spSession->RegisterNameSpace(m_spCFHTTPS, CLSID_HttpSProtocol, L"https", 0, 0, 0);
63 if (FAILED(hr))
64 {
65 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_REGISTER_HTTP S_NAMESPACE, "MimeClient::RegisterNameSpace failed");
66 return;
67 }
68
69 }
70
71
72 CPluginAppNamespaceClient::~CPluginAppNamespaceClient()
73 {
74 CComPtr<IInternetSession> spSession;
75
76 ::CoInternetGetSession(0, &spSession, 0);
77 if (spSession)
78 {
Eric 2015/05/16 21:00:48 We are manually unregistering both name spaces wit
79 spSession->UnregisterNameSpace(m_spCFHTTP, L"http");
80 if (m_spCFHTTP != NULL)
81 {
82 m_spCFHTTP.Release();
83 m_spCFHTTP = NULL;
84 }
85 spSession->UnregisterNameSpace(m_spCFHTTPS, L"https");
86 if (m_spCFHTTPS != NULL)
87 {
88 m_spCFHTTPS.Release();
89 m_spCFHTTPS = NULL;
90 }
91
92 }
93 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld