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

Unified Diff: src/plugin/PluginAppNamespaceClient.cpp

Issue 5032147387678720: NoIssue - Refactor HTTP and HTTPS namespaces registration
Patch Set: Fix the renaming patchset Created April 24, 2015, 11:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginAppNamespaceClient.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/plugin/PluginAppNamespaceClient.cpp
@@ -0,0 +1,93 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PluginStdAfx.h"
+
+#include "PluginAppNamespaceClient.h"
+#include "PluginClient.h"
+#include "PluginWbPassThrough.h"
+
+
+typedef PassthroughAPP::CMetaFactory<PassthroughAPP::CComClassFactoryProtocol,WBPassthru> MetaFactory;
Eric 2015/05/16 21:00:48 This definition could go in an anonymous namespace
+
+
+CPluginAppNamespaceClient::CPluginAppNamespaceClient() : m_spCFHTTP(NULL), m_spCFHTTPS(NULL)
+{
+ // Should only be called once
+ // We register mime filters here
+ // Register asynchronous protocol
+ CComPtr<IInternetSession> spSession;
Eric 2015/05/16 21:00:48 We're also calling 'CoInternetGetSession' in the d
+ HRESULT hr = ::CoInternetGetSession(0, &spSession, 0);
+ if (FAILED(hr) || !spSession)
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_GET_INTERNET_SESSION, "MimeClient::CoInternetGetSession failed");
+ return;
+ }
+
+ hr = MetaFactory::CreateInstance(CLSID_HttpProtocol, &m_spCFHTTP);
Eric 2015/05/16 21:00:48 The invocation of 'CreateInstance' starts a memory
+ if (FAILED(hr) || !m_spCFHTTP)
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_CREATE_HTTP_INSTANCE, "MimeClient::CreateInstance failed");
+ return;
+ }
+
+ hr = spSession->RegisterNameSpace(m_spCFHTTP, CLSID_HttpProtocol, L"http", 0, 0, 0);
+ if (FAILED(hr))
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_REGISTER_HTTP_NAMESPACE, "MimeClient::RegisterNameSpace failed");
+ return;
+ }
+
+ hr = MetaFactory::CreateInstance(CLSID_HttpSProtocol, &m_spCFHTTPS);
+ if (FAILED(hr) || !m_spCFHTTPS)
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_CREATE_HTTPS_INSTANCE, "MimeClient::CreateInstance failed");
+ return;
Eric 2015/05/16 21:00:48 If the "http" handler registers correctly, but thi
+ }
+
+ hr = spSession->RegisterNameSpace(m_spCFHTTPS, CLSID_HttpSProtocol, L"https", 0, 0, 0);
+ if (FAILED(hr))
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SESSION, PLUGIN_ERROR_SESSION_REGISTER_HTTPS_NAMESPACE, "MimeClient::RegisterNameSpace failed");
+ return;
+ }
+
+}
+
+
+CPluginAppNamespaceClient::~CPluginAppNamespaceClient()
+{
+ CComPtr<IInternetSession> spSession;
+
+ ::CoInternetGetSession(0, &spSession, 0);
+ if (spSession)
+ {
Eric 2015/05/16 21:00:48 We are manually unregistering both name spaces wit
+ spSession->UnregisterNameSpace(m_spCFHTTP, L"http");
+ if (m_spCFHTTP != NULL)
+ {
+ m_spCFHTTP.Release();
+ m_spCFHTTP = NULL;
+ }
+ spSession->UnregisterNameSpace(m_spCFHTTPS, L"https");
+ if (m_spCFHTTPS != NULL)
+ {
+ m_spCFHTTPS.Release();
+ m_spCFHTTPS = NULL;
+ }
+
+ }
+}

Powered by Google App Engine
This is Rietveld