Remove parent* arg from GDataEntry ctor.

* Remove static FromDocumentEntry from GDataEntry, GDataFile, GDataDirectory. Replace with InitFromDocumentEntry.
* Move common code from GDataFile::InitFromDocumentEntry and GDataDirectory::InitFromDocumentEntry to GDataEntry::InitFromDocumentEntry.
* Add GDataDirectoryService::FromDocumentEntry and use this everywhere.
* Make ctors of GDataFile, GDataDirectory private, so these must be created by GDataDirectoryService's CreateGDataFile and
CreateGDataDirectory. Make GDataEntry ctor protected.

BUG=141494
TEST=unit tests.
Review URL: https://chromiumcodereview.appspot.com/10854083

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151008 0039d316-1c4b-4281-b951-d872f2087c98
void GDataFileSystem::RenameFileOnFileSystem(
    const FilePath& file_path,
    const FilePath::StringType& new_name,
    const FileMoveCallback& callback,
    GDataErrorCode status,
    const GURL& document_url) {
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

  const GDataFileError error = util::GDataToGDataFileError(status);
  if (error != GDATA_FILE_OK) {
    if (!callback.is_null())
      callback.Run(error, FilePath());
    return;
  }

  GDataEntry* entry = directory_service_->FindEntryByPathSync(file_path);
  if (!entry) {
    if (!callback.is_null())
      callback.Run(GDATA_FILE_ERROR_NOT_FOUND, FilePath());
    return;
  }

  DCHECK(entry->parent());
  entry->set_title(new_name);
  directory_service_->MoveEntryToDirectory(
      entry->parent()->GetFilePath(),
      entry,
      base::Bind(&GDataFileSystem::OnMoveEntryToDirectoryWithFileMoveCallback,
                 ui_weak_ptr_,
                 callback));
}

void GDataFileSystem::RenameFileOnFileSystem(
    const FilePath& file_path,
    const FilePath::StringType& new_name,
    const FileMoveCallback& callback,
    GDataErrorCode status,
    const GURL& document_url) {
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

  const GDataFileError error = util::GDataToGDataFileError(status);
  if (error != GDATA_FILE_OK) {
    if (!callback.is_null())
      callback.Run(error, FilePath());
    return;
  }

  GDataEntry* entry = directory_service_->FindEntryByPathSync(file_path);
  if (!entry) {
    if (!callback.is_null())
      callback.Run(GDATA_FILE_ERROR_NOT_FOUND, FilePath());
    return;
  }

  DCHECK(entry->parent());
  entry->set_title(new_name);
  directory_service_->MoveEntryToDirectory(
      entry->parent()->GetFilePath(),
      entry,
      base::Bind(&GDataFileSystem::OnMoveEntryToDirectoryWithFileMoveCallback,
                 ui_weak_ptr_,
                 callback));
}
