summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Core')
-rw-r--r--src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Channel.cs5
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessageProtectionTasks.cs35
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs12
4 files changed, 48 insertions, 5 deletions
diff --git a/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj b/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
index 6537c05..7877cf0 100644
--- a/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
+++ b/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
@@ -29,6 +29,7 @@
<Compile Include="Messaging\Bindings\ICryptoKeyStore.cs" />
<Compile Include="Messaging\Bindings\MemoryCryptoKeyStore.cs" />
<Compile Include="Messaging\BinaryDataBagFormatter.cs" />
+ <Compile Include="Messaging\MessageProtectionTasks.cs" />
<Compile Include="Messaging\MultipartContentMember.cs" />
<Compile Include="Messaging\DataBagFormatterBase.cs" />
<Compile Include="Messaging\HmacAlgorithms.cs" />
diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
index a134180..e36bb94 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
@@ -140,11 +140,6 @@ namespace DotNetOpenAuth.Messaging {
private IMessageFactory messageTypeProvider;
/// <summary>
- /// Backing store for the <see cref="CachePolicy"/> property.
- /// </summary>
- private RequestCachePolicy cachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
-
- /// <summary>
/// Backing field for the <see cref="MaximumIndirectMessageUrlLength"/> property.
/// </summary>
private int maximumIndirectMessageUrlLength = Configuration.DotNetOpenAuthSection.Messaging.MaximumIndirectMessageUrlLength;
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessageProtectionTasks.cs b/src/DotNetOpenAuth.Core/Messaging/MessageProtectionTasks.cs
new file mode 100644
index 0000000..29163f7
--- /dev/null
+++ b/src/DotNetOpenAuth.Core/Messaging/MessageProtectionTasks.cs
@@ -0,0 +1,35 @@
+//-----------------------------------------------------------------------
+// <copyright file="MessageProtectionTasks.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Messaging {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+
+ /// <summary>
+ /// Reusable pre-completed tasks that may be returned multiple times to reduce GC pressure.
+ /// </summary>
+ internal static class MessageProtectionTasks {
+ /// <summary>
+ /// A task whose result is <c>null</c>
+ /// </summary>
+ internal static readonly Task<MessageProtections?> Null = Task.FromResult<MessageProtections?>(null);
+
+ /// <summary>
+ /// A task whose result is <see cref="MessageProtections.None"/>
+ /// </summary>
+ internal static readonly Task<MessageProtections?> None =
+ Task.FromResult<MessageProtections?>(MessageProtections.None);
+
+ /// <summary>
+ /// A task whose result is <see cref="MessageProtections.TamperProtection"/>
+ /// </summary>
+ internal static readonly Task<MessageProtections?> TamperProtection =
+ Task.FromResult<MessageProtections?>(MessageProtections.TamperProtection);
+ }
+}
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index b84bd48..a4aff73 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -88,6 +88,11 @@ namespace DotNetOpenAuth.Messaging {
private const int SymmetricSecretHandleLength = 4;
/// <summary>
+ /// A pre-completed task.
+ /// </summary>
+ private static readonly Task CompletedTaskField = Task.FromResult<object>(null);
+
+ /// <summary>
/// The default lifetime of a private secret.
/// </summary>
private static readonly TimeSpan SymmetricSecretKeyLifespan = Configuration.DotNetOpenAuthSection.Messaging.PrivateSecretMaximumAge;
@@ -151,6 +156,13 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Gets a pre-completed task.
+ /// </summary>
+ internal static Task CompletedTask {
+ get { return CompletedTaskField; }
+ }
+
+ /// <summary>
/// Gets a random number generator for use on the current thread only.
/// </summary>
internal static Random NonCryptoRandomDataGenerator {