[mono/monodevelop] [3 commits] b6be0f10: [Core] Make sure WebService is initialized framework service

"Michael Hutchinson ([email protected])" <[email protected]> Mon, 18 Nov 2013 23:58:11 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001426da66866-f41a3c04-8e5d-4439-8c63-9a7ea63c0197-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/710e04007b0a...076f1b9d0af0

   Commit: b6be0f1030dee54a26fd626602e3f862159d10ba
   Author: Michael Hutchinson <[email protected]> (mhutch)
     Date: 2013-11-18 23:38:33 GMT
      URL: https://github.com/mono/monodevelop/commit/b6be0f1030dee54a26fd626602e3f862159d10ba

[Core] Make sure WebService is initialized framework service

The framework service can kick off the activation system, which
makes web requests.

BXC16245 - [XS]Upgrade workflow throws an NRE while trying to activate
a license

Changed paths:
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs

Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs
===================================================================
@@ -112,6 +112,7 @@ public static void Initialize (bool updateAddinRegistry)
 				Counters.RuntimeInitialization.Trace ("Initialized Addin Manager");
 				
 				PropertyService.Initialize ();
+				WebService.Initialize ();
 				
 				//have to do this after the addin service and property service have initialized
 				if (UserDataMigrationService.HasSource) {
@@ -124,8 +125,6 @@ public static void Initialize (bool updateAddinRegistry)
 				Counters.RuntimeInitialization.Trace ("Initializing Assembly Service");
 				systemAssemblyService = new SystemAssemblyService ();
 				systemAssemblyService.Initialize ();
-
-				WebService.Initialize ();
 				
 				initialized = true;
 				

   Commit: 66462c816c7cb207e3f84b3bd9cb334f6db5db94
   Author: Michael Hutchinson <[email protected]> (mhutch)
     Date: 2013-11-18 23:38:33 GMT
      URL: https://github.com/mono/monodevelop/commit/66462c816c7cb207e3f84b3bd9cb334f6db5db94

[Core] Clean up the WebService

Had lots of pointless lazies and singletons, and could explode on
platforms without a credentials provider.

Changed paths:
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/CredentialStore.cs
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/ICredentialProvider.cs
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/ProxyCache.cs
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/RequestHelper.cs
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/WebService.cs
  M main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs

Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/CredentialStore.cs
===================================================================
@@ -7,13 +7,6 @@ namespace MonoDevelop.Core.Web
 	class CredentialStore : ICredentialCache
 	{
 		readonly ConcurrentDictionary<Uri, ICredentials> credentialCache = new ConcurrentDictionary<Uri, ICredentials> ();
-		static readonly CredentialStore instance = new CredentialStore ();
-
-		public static CredentialStore Instance {
-			get {
-				return instance;
-			}
-		}
 
 		public ICredentials GetCredentials (Uri uri, CredentialType credentialType)
 		{


Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/ICredentialProvider.cs
===================================================================
@@ -10,7 +10,7 @@ namespace MonoDevelop.Core.Web
 	public interface ICredentialProvider
 	{
 		/// <summary>
-		/// Returns CredentialState state that let's the consumer know if ICredentials
+		/// Returns CredentialState state that lets the consumer know if ICredentials
 		/// were discovered by the ICredentialProvider. The credentials argument is then
 		/// populated with the discovered valid credentials that can be used for the given Uri.
 		/// The proxy instance if passed will be used to ensure that the request goes through the proxy

Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/ProxyCache.cs
===================================================================
@@ -14,15 +14,6 @@ class ProxyCache : IProxyCache
 		static readonly IWebProxy originalSystemProxy = WebRequest.GetSystemWebProxy ();
 
 		readonly ConcurrentDictionary<Uri, WebProxy> cache = new ConcurrentDictionary<Uri, WebProxy> ();
-		static readonly Lazy<ProxyCache> instance = new Lazy<ProxyCache> (() => new ProxyCache ());
-
-		public static ProxyCache Instance {
-			get {
-				return instance.Value;
-			}
-		}
-
-		ProxyCache () {}
 
 		public IWebProxy GetProxy (Uri uri)
 		{

Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/RequestHelper.cs
===================================================================
@@ -13,9 +13,9 @@ public static class RequestHelper
 		/// </summary>
 		internal static WebResponse GetResponse (Func<WebRequest> createRequest, Action<WebRequest> prepareRequest)
 		{
-			var proxyCache = WebService.Instance.ProxyCache;
-			var credentialCache = WebService.Instance.CredentialCache;
-			var credentialProvider = WebService.Instance.CredentialProvider;
+			var proxyCache = WebService.ProxyCache;
+			var credentialCache = WebService.CredentialCache;
+			var credentialProvider = WebService.CredentialProvider;
 
 			HttpWebRequest previousRequest = null;
 			IHttpWebResponse previousResponse = null;


Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core.Web/WebService.cs
===================================================================
@@ -23,40 +23,42 @@
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
+
 using System;
 using System.Linq;
 
 using Mono.Addins;
+using System.Net;
 
 namespace MonoDevelop.Core.Web
 {
-	public class WebService
+	public static class WebService
 	{
 		const string WebCredentialProvidersPath = "/MonoDevelop/Core/WebCredentialProviders";
 
-		static readonly Lazy<WebService> instance = new Lazy<WebService> (() => new WebService ());
+		public static IProxyCache ProxyCache { get; private set; }
+		public static ICredentialCache CredentialCache { get; private set; }
+		public static ICredentialProvider CredentialProvider { get; private set; }
 
-		public static WebService Instance {
-			get {
-				return instance.Value;
-			}
-		}
+		internal static void Initialize ()
+		{
+			CredentialCache = new CredentialStore ();
+			ProxyCache = new ProxyCache ();
+			CredentialProvider = AddinManager.GetExtensionObjects<ICredentialProvider> (WebCredentialProvidersPath).FirstOrDefault ();
 
-		public IProxyCache ProxyCache { get; set; }
-		public ICredentialCache CredentialCache { get; set; }
-		public ICredentialProvider CredentialProvider { get; set; }
+			if (CredentialProvider == null) {
+				LoggingService.LogWarning ("No proxy credential provider was found");
 
-		WebService () {}
+			}
+		}
 
-		public static void Initialize ()
+		class NullCredentialsProvider : ICredentialProvider
 		{
-			// We can access extension points now, so we need to get the credential provider, which is platform-specific.
-			// The credential cache and proxy cache are pure managed implementation.
-			Instance.CredentialCache = CredentialStore.Instance;
-			Instance.ProxyCache = Web.ProxyCache.Instance;
-
-			// Get the first registered credential provider
-			Instance.CredentialProvider = AddinManager.GetExtensionObjects<ICredentialProvider> (WebCredentialProvidersPath).FirstOrDefault ();
+			public ICredentials GetCredentials (
+				Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying)
+			{
+				return null;
+			}
 		}
 	}
 }

Modified: main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs
===================================================================
@@ -85,7 +85,7 @@ public static void Initialize (bool updateAddinRegistry)
 				SynchronizationContext.SetSynchronizationContext (new SynchronizationContext ());
 
 			// Hook up the SSL certificate validation codepath
-			System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
+			ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
 				if (sslPolicyErrors == SslPolicyErrors.None)
 					return true;
 				

   Commit: 076f1b9d0af040ea747bd3341f09a2d84eb2b3fa
   Author: Michael Hutchinson <[email protected]> (mhutch)
     Date: 2013-11-18 23:51:56 GMT
      URL: https://github.com/mono/monodevelop/commit/076f1b9d0af040ea747bd3341f09a2d84eb2b3fa

[md-addins] Bump to track WebService API

Changed paths:
  M version-checks

Modified: version-checks
===================================================================
@@ -17,7 +17,7 @@ DEP[0]=md-addins
 DEP_NAME[0]=MDADDINS
 DEP_PATH[0]=${top_srcdir}/../md-addins
 DEP_MODULE[0][email protected]:xamarin/md-addins.git
-DEP_NEEDED_VERSION[0]=4ea04da6b207adaed578b269d988f1ae3f6021fa
+DEP_NEEDED_VERSION[0]=c51ee3b3e1cd47f3fb2886b731ef98e83e138e21
 DEP_BRANCH_AND_REMOTE[0]="master origin/master"
 
 # heap-shot


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches