       callback(data)
     )
 
-  insert: (title, content, callback) ->
+  insert: (title, content) ->
     multipartRequestBody = this.requestBody(title, content)
-    # memo: gapi.client.requestはpromiseも使えるらしい
-    # https://developers.google.com/api-client-library/javascript/features/promises
-    request = gapi.client.request({
+    # Promise互換を返す
+    return gapi.client.request({
       'path': '/upload/drive/v2/files',
       'method': 'POST',
       'params': {'uploadType': 'multipart'},

      callback(file, caller)
    )

  upload: (title, content, callback, caller) ->
    this.set({title: title, content: content})

    if this.get("file")
      this.update(title, content, callback, caller)
    else
      this.insert(title, content, callback, caller)

  insert: (title, content, callback, caller) ->
    that = this
    # memo: gapi.client.loadはGDriveオブジェクトの方に移したい
    # さらにclient.loadはcallback無しのときにpromiseが返るらしい
    # https://developers.google.com/api-client-library/javascript/reference/referencedocs
    gapi.client.load('drive', 'v2', ->
      that.gdrive.insert(title, content, (file)->
        console.log("insert file")
        console.log(file)
        that.set("file", file)

        callback(file, "insert", caller)
        )
    )

  update: (title, content, callback, caller) ->
    that = this

    this.alertView = options.alertView # modelなどの特別以外は明示的に受け取る必要がある
    this.model_handler = options.modelHandler

    this.listenTo(this.model, 'change:file', this.updateDocumentLink)

  gapi_authorize: ()->
    this.model.authorize()
      .then () =>
        this.alertView.show("success", "Success GoogleDrive authorization")
