media: Move CdmInitializedPromise to media/.

This class does not need to be in content/ and will be needed by MojoCdm in
media/mojo.

BUG=432998
TEST=Moves file only.

Review URL: https://codereview.chromium.org/1187603003

Cr-Commit-Position: refs/heads/master@{#334266}
diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn
index 96254cf2..2232b971 100644
--- a/media/base/BUILD.gn
+++ b/media/base/BUILD.gn
@@ -68,6 +68,8 @@
     "cdm_context.h",
     "cdm_factory.cc",
     "cdm_factory.h",
+    "cdm_initialized_promise.cc",
+    "cdm_initialized_promise.h",
     "cdm_key_information.cc",
     "cdm_key_information.h",
     "cdm_promise.cc",
diff --git a/media/base/cdm_callback_promise.h b/media/base/cdm_callback_promise.h
index e08d95f..8685c17 100644
--- a/media/base/cdm_callback_promise.h
+++ b/media/base/cdm_callback_promise.h
@@ -34,7 +34,7 @@
                       const std::string& error_message) override;
 
  private:
-  using media::CdmPromiseTemplate<T...>::MarkPromiseSettled;
+  using CdmPromiseTemplate<T...>::MarkPromiseSettled;
 
   base::Callback<void(const T&...)> resolve_cb_;
   PromiseRejectedCB reject_cb_;
diff --git a/media/base/cdm_initialized_promise.cc b/media/base/cdm_initialized_promise.cc
new file mode 100644
index 0000000..dcc9c79c
--- /dev/null
+++ b/media/base/cdm_initialized_promise.cc
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/cdm_initialized_promise.h"
+
+namespace media {
+
+CdmInitializedPromise::CdmInitializedPromise(const CdmCreatedCB& cdm_created_cb,
+                                             scoped_ptr<MediaKeys> cdm)
+    : cdm_created_cb_(cdm_created_cb), cdm_(cdm.Pass()) {
+}
+
+CdmInitializedPromise::~CdmInitializedPromise() {
+}
+
+void CdmInitializedPromise::resolve() {
+  MarkPromiseSettled();
+  cdm_created_cb_.Run(cdm_.Pass(), "");
+}
+
+void CdmInitializedPromise::reject(MediaKeys::Exception exception_code,
+                                   uint32 system_code,
+                                   const std::string& error_message) {
+  MarkPromiseSettled();
+  cdm_created_cb_.Run(nullptr, error_message);
+  // Usually after this |this| (and the |cdm_| within it) will be destroyed.
+}
+
+}  // namespace media
diff --git a/media/base/cdm_initialized_promise.h b/media/base/cdm_initialized_promise.h
new file mode 100644
index 0000000..bc4a5697
--- /dev/null
+++ b/media/base/cdm_initialized_promise.h
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_
+#define MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "media/base/cdm_factory.h"
+#include "media/base/cdm_promise.h"
+#include "media/base/media_export.h"
+#include "media/base/media_keys.h"
+
+namespace media {
+
+// Promise to be resolved when the CDM is initialized. It owns the MediaKeys
+// object until the initialization completes, which it then passes to
+// |cdm_created_cb|.
+class MEDIA_EXPORT CdmInitializedPromise : public SimpleCdmPromise {
+ public:
+  CdmInitializedPromise(const CdmCreatedCB& cdm_created_cb,
+                        scoped_ptr<MediaKeys> cdm);
+  ~CdmInitializedPromise() override;
+
+  // SimpleCdmPromise implementation.
+  void resolve() override;
+  void reject(MediaKeys::Exception exception_code,
+              uint32 system_code,
+              const std::string& error_message) override;
+
+ private:
+  CdmCreatedCB cdm_created_cb_;
+  scoped_ptr<MediaKeys> cdm_;
+};
+
+}  // namespace media
+
+#endif  // MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_