示例#1
0
	bool StartBurn()
	{
		NotifyProgress(0.0);

		// detail progress

		NotifyProgress(1.0);

		return true;
	}
示例#2
0
void Driver::HandleLoadDatabaseContentEvent(events::LoadDatabaseContentRequestEvent* ev) {
  QObject* sender = ev->sender();
  NotifyProgress(sender, 0);
  events::LoadDatabaseContentResponceEvent::value_type res(ev->value());
  std::string patternResult = common::MemSPrintf(SSDB_GET_KEYS_PATTERN_1ARGS_I, res.count_keys);
  FastoObjectCommandIPtr cmd = CreateCommandFast(patternResult, common::Value::C_INNER);
  NotifyProgress(sender, 50);
  common::Error err = Execute(cmd);
  if (err && err->isError()) {
    res.setErrorInfo(err);
  } else {
    FastoObject::childs_t rchildrens = cmd->Childrens();
    if (rchildrens.size()) {
      CHECK_EQ(rchildrens.size(), 1);
      FastoObjectArray* array = dynamic_cast<FastoObjectArray*>(rchildrens[0].get());  // +
      if (!array) {
        goto done;
      }
      common::ArrayValue* ar = array->Array();
      if (!ar) {
        goto done;
      }

      for (size_t i = 0; i < ar->size(); ++i) {
        std::string key;
        if (ar->getString(i, &key)) {
          NKey k(key);
          FastoObjectCommandIPtr cmd_ttl =
              CreateCommandFast(common::MemSPrintf("TTL %s", key), common::Value::C_INNER);
          LOG_COMMAND(cmd_ttl);
          ttl_t ttl = NO_TTL;
          common::Error err = impl_->TTL(key, &ttl);
          if (err && err->isError()) {
            k.SetTTL(NO_TTL);
          } else {
            k.SetTTL(ttl);
          }

          NValue empty_val(common::Value::createEmptyValueFromType(common::Value::TYPE_STRING));
          NDbKValue ress(k, empty_val);
          res.keys.push_back(ress);
        }
      }

      err = impl_->DBkcount(&res.db_keys_count);
      DCHECK(!err);
    }
  }
done:
  NotifyProgress(sender, 75);
  Reply(sender, new events::LoadDatabaseContentResponceEvent(this, res));
  NotifyProgress(sender, 100);
}
// ----------------------------------------------------------------------------
// CSamplerPluginLoader::LoadRlibraryL
// ----------------------------------------------------------------------------
//
void CSamplerPluginLoader::LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray)
    {
    LOGSTRING("CSamplerPluginLoader rlibrary loading");
                // Load dll
    iPluginArray = aPluginArray;
    RLibrary aLib;
    TInt ret = aLib.Load(_L("PIProfilerGenerals.dll"),_L("c:\\sys\\bin"));

    LOGSTRING2("RLibrary load returns %d", ret);
    User::LeaveIfError(ret);
    const TInt KNewLOrdinal = 2;
    TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal);

    if(!NewL)
        {
        RDebug::Printf("library.lookup returns null");    
        }
    else
        {
        LOGSTRING2("library.lookup returns 0x%x", NewL);
        //CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL();
        CSamplerPluginInterface* mydll=(CSamplerPluginInterface*)NewL();
        //Generals plugin loaded, samplers enabled.
        CleanupStack::PushL( mydll );
        //InsertPluginInOrderL( mydll, aPluginArray);
        CleanupStack::Pop(mydll);
        // call engine to finalize the startup
        //TRAPD(result, iObserver->HandleSamplerControllerReadyL(););
        NotifyProgress();

        //Begin CActive asynchronous loop.
        CompleteOwnRequest();
        }
    LOGSTRING("RLibrary and plugins loaded");
    }
示例#4
0
void
AnimationDecodingTask::Run()
{
  while (true) {
    LexerResult result = mDecoder->Decode(WrapNotNull(this));

    if (result.is<TerminalState>()) {
      NotifyDecodeComplete(mDecoder->GetImage(), mDecoder);
      return;  // We're done.
    }

    MOZ_ASSERT(result.is<Yield>());

    // Notify for the progress we've made so far.
    if (mDecoder->HasProgress()) {
      NotifyProgress(mDecoder->GetImage(), mDecoder);
    }

    if (result == LexerResult(Yield::NEED_MORE_DATA)) {
      // We can't make any more progress right now. The decoder itself will
      // ensure that we get reenqueued when more data is available; just return
      // for now.
      return;
    }

    // Right now we don't do anything special for other kinds of yields, so just
    // keep working.
  }
}
示例#5
0
//******************************************************************************
NS_IMETHODIMP
RasterImage::ResetAnimation()
{
  if (mError) {
    return NS_ERROR_FAILURE;
    }

  mPendingAnimation = false;

  if (mAnimationMode == kDontAnimMode || !mAnimationState ||
      mAnimationState->GetCurrentAnimationFrameIndex() == 0) {
    return NS_OK;
  }

  mAnimationFinished = false;

  if (mAnimating) {
    StopAnimation();
  }

  MOZ_ASSERT(mAnimationState, "Should have AnimationState");
  mAnimationState->ResetAnimation();

  NotifyProgress(NoProgress, mAnimationState->FirstFrameRefreshArea());

  // Start the animation again. It may not have been running before, if
  // mAnimationFinished was true before entering this function.
  EvaluateAnimation();

  return NS_OK;
}
示例#6
0
nsresult
RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
                                 bool aLastPart)
{
  MOZ_ASSERT(NS_IsMainThread());

  // Record that we have all the data we're going to get now.
  mHasSourceData = true;

  // Let decoders know that there won't be any more data coming.
  mSourceBuffer->Complete(aStatus);

  // Allow a synchronous metadata decode if mSyncLoad was set, or if we're
  // running on a single thread (in which case waiting for the async metadata
  // decoder could delay this image's load event quite a bit), or if this image
  // is transient.
  bool canSyncDecodeMetadata = mSyncLoad || mTransient ||
                               DecodePool::NumberOfCores() < 2;

  if (canSyncDecodeMetadata && !mHasSize) {
    // We're loading this image synchronously, so it needs to be usable after
    // this call returns.  Since we haven't gotten our size yet, we need to do a
    // synchronous metadata decode here.
    DecodeMetadata(FLAG_SYNC_DECODE);
  }

  // Determine our final status, giving precedence to Necko failure codes. We
  // check after running the metadata decode in case it triggered an error.
  nsresult finalStatus = mError ? NS_ERROR_FAILURE : NS_OK;
  if (NS_FAILED(aStatus)) {
    finalStatus = aStatus;
  }

  // If loading failed, report an error.
  if (NS_FAILED(finalStatus)) {
    DoError();
  }

  Progress loadProgress = LoadCompleteProgress(aLastPart, mError, finalStatus);

  if (!mHasSize && !mError) {
    // We don't have our size yet, so we'll fire the load event in SetSize().
    MOZ_ASSERT(!canSyncDecodeMetadata,
               "Firing load async after metadata sync decode?");
    NotifyProgress(FLAG_ONLOAD_BLOCKED);
    mLoadProgress = Some(loadProgress);
    return finalStatus;
  }

  NotifyForLoadEvent(loadProgress);

  return finalStatus;
}
// ----------------------------------------------------------------------------
// CWriterPluginLoader::LoadAsync
//
//
// ----------------------------------------------------------------------------
//
void CWriterPluginLoader::LoadAsyncL( CArrayPtrFlat<CWriterPluginInterface>* aPluginArray )
    {
    iPluginArray = aPluginArray;
    
    // Reset iterator:
    iImplInfoArrayIterator = 0;

    LOGSTRING2( "CWriterPluginLoader()::Implementation info count: %d",
        iImplInfoArray.Count() );

    NotifyProgress();

    //Begin CActive asynchronous loop.
    CompleteOwnRequest();
    }
示例#8
0
void
RasterImage::NotifyForLoadEvent(Progress aProgress)
{
  MOZ_ASSERT(mHasSize || mError, "Need to know size before firing load event");
  MOZ_ASSERT(!mHasSize ||
             (mProgressTracker->GetProgress() & FLAG_SIZE_AVAILABLE),
             "Should have notified that the size is available if we have it");

  // If we encountered an error, make sure we notify for that as well.
  if (mError) {
    aProgress |= FLAG_HAS_ERROR;
  }

  // Notify our listeners, which will fire this image's load event.
  NotifyProgress(aProgress);
}
示例#9
0
void
DecodingTask::Run()
{
  nsresult rv = mDecoder->Decode(WrapNotNull(this));

  if (NS_SUCCEEDED(rv) && !mDecoder->GetDecodeDone()) {
    // Notify for the progress we've made so far.
    if (mDecoder->HasProgress()) {
      NotifyProgress(mDecoder);
    }

    // We don't need to do anything else for this case. The decoder itself will
    // ensure that we get reenqueued when more data is available.
    return;
  }

  NotifyDecodeComplete(mDecoder);
}
void
AnimationSurfaceProvider::Run()
{
  MutexAutoLock lock(mDecodingMutex);

  if (!mDecoder || !mImage) {
    MOZ_ASSERT_UNREACHABLE("Running after decoding finished?");
    return;
  }

  while (true) {
    // Run the decoder.
    LexerResult result = mDecoder->Decode(WrapNotNull(this));

    if (result.is<TerminalState>()) {
      // We may have a new frame now, but it's not guaranteed - a decoding
      // failure or truncated data may mean that no new frame got produced.
      // Since we're not sure, rather than call CheckForNewFrameAtYield() here
      // we call CheckForNewFrameAtTerminalState(), which handles both of these
      // possibilities.
      CheckForNewFrameAtTerminalState();

      // We're done!
      FinishDecoding();
      return;
    }

    // Notify for the progress we've made so far.
    if (mDecoder->HasProgress()) {
      NotifyProgress(WrapNotNull(mImage), WrapNotNull(mDecoder));
    }

    if (result == LexerResult(Yield::NEED_MORE_DATA)) {
      // We can't make any more progress right now. The decoder itself will ensure
      // that we get reenqueued when more data is available; just return for now.
      return;
    }

    // There's new output available - a new frame! Grab it.
    MOZ_ASSERT(result == LexerResult(Yield::OUTPUT_AVAILABLE));
    CheckForNewFrameAtYield();
  }
}
void
DecodedSurfaceProvider::Run()
{
  MutexAutoLock lock(mMutex);

  if (!mDecoder || !mImage) {
    MOZ_ASSERT_UNREACHABLE("Running after decoding finished?");
    return;
  }

  // Run the decoder.
  LexerResult result = mDecoder->Decode(WrapNotNull(this));

  // If there's a new surface available, announce it to the surface cache.
  CheckForNewSurface();

  if (result.is<TerminalState>()) {
    FinishDecoding();
    return;  // We're done.
  }

  // Notify for the progress we've made so far.
  if (mDecoder->HasProgress()) {
    NotifyProgress(WrapNotNull(mImage), WrapNotNull(mDecoder));
  }

  MOZ_ASSERT(result.is<Yield>());

  if (result == LexerResult(Yield::NEED_MORE_DATA)) {
    // We can't make any more progress right now. The decoder itself will ensure
    // that we get reenqueued when more data is available; just return for now.
    return;
  }

  // Single-frame images shouldn't yield for any reason except NEED_MORE_DATA.
  MOZ_ASSERT_UNREACHABLE("Unexpected yield for single-frame image");
  mDecoder->TerminateFailure();
  FinishDecoding();
}
示例#12
0
// Indempotent error flagging routine. If a decoder is open, shuts it down.
void
RasterImage::DoError()
{
  // If we've flagged an error before, we have nothing to do
  if (mError) {
    return;
  }

  // We can't safely handle errors off-main-thread, so dispatch a worker to
  // do it.
  if (!NS_IsMainThread()) {
    HandleErrorWorker::DispatchIfNeeded(this);
    return;
  }

  // Put the container in an error state.
  mError = true;

  // Stop animation and release our FrameAnimator.
  if (mAnimating) {
    StopAnimation();
  }
  mAnimationState = Nothing();
  mFrameAnimator = nullptr;

  // Release all locks.
  mLockCount = 0;
  SurfaceCache::UnlockImage(ImageKey(this));

  // Release all frames from the surface cache.
  SurfaceCache::RemoveImage(ImageKey(this));

  // Invalidate to get rid of any partially-drawn image content.
  NotifyProgress(NoProgress, IntRect(0, 0, mSize.width, mSize.height));

  MOZ_LOG(gImgLog, LogLevel::Error,
          ("RasterImage: [this=%p] Error detected for image\n", this));
}
示例#13
0
void Driver::HandleLoadDatabaseContentEvent(events::LoadDatabaseContentRequestEvent* ev) {
  QObject* sender = ev->sender();
  NotifyProgress(sender, 0);
  events::LoadDatabaseContentResponceEvent::value_type res(ev->value());
  std::string patternResult =
      common::MemSPrintf(GET_KEYS_PATTERN_3ARGS_ISI, res.cursor_in, res.pattern, res.count_keys);
  FastoObjectCommandIPtr cmd = CreateCommandFast(patternResult, common::Value::C_INNER);
  NotifyProgress(sender, 50);
  common::Error er = Execute(cmd);
  if (er && er->isError()) {
    res.setErrorInfo(er);
  } else {
    FastoObject::childs_t rchildrens = cmd->Childrens();
    if (rchildrens.size()) {
      CHECK_EQ(rchildrens.size(), 1);
      FastoObjectArray* array = dynamic_cast<FastoObjectArray*>(rchildrens[0].get());  // +
      if (!array) {
        goto done;
      }

      common::ArrayValue* arm = array->Array();
      if (!arm->size()) {
        goto done;
      }

      std::string cursor;
      bool isok = arm->getString(0, &cursor);
      if (!isok) {
        goto done;
      }

      res.cursor_out = common::ConvertFromString<uint64_t>(cursor);

      rchildrens = array->Childrens();
      if (!rchildrens.size()) {
        goto done;
      }

      FastoObject* obj = rchildrens[0].get();
      FastoObjectArray* arr = dynamic_cast<FastoObjectArray*>(obj);  // +
      if (!arr) {
        goto done;
      }

      common::ArrayValue* ar = arr->Array();
      if (ar->empty()) {
        goto done;
      }

      for (size_t i = 0; i < ar->size(); ++i) {
        std::string key;
        if (ar->getString(i, &key)) {
          NKey k(key);
          NValue empty_val(common::Value::createEmptyValueFromType(common::Value::TYPE_STRING));
          NDbKValue ress(k, empty_val);
          res.keys.push_back(ress);
        }
      }

      common::Error err = impl_->DBkcount(&res.db_keys_count);
      DCHECK(!err);
    }
  }
done:
  NotifyProgress(sender, 75);
  Reply(sender, new events::LoadDatabaseContentResponceEvent(this, res));
  NotifyProgress(sender, 100);
}
/*! バッファ内容をファイルに書き出す (テスト用)

	@note Windows用にコーディングしてある
	@date 2003.07.26 ryoji BOM引数追加
*/
EConvertResult CWriteManager::WriteFile_From_CDocLineMgr(
	const CDocLineMgr&	pcDocLineMgr,	//!< [in]
	const SSaveInfo&	sSaveInfo		//!< [in]
)
{
	EConvertResult		nRetVal = RESULT_COMPLETE;
	std::auto_ptr<CCodeBase> pcCodeBase( CCodeFactory::CreateCodeBase(sSaveInfo.eCharCode,0) );

	{
		// 変換テスト
		CNativeW buffer = L"abcde";
		CMemory tmp;
		EConvertResult e = pcCodeBase->UnicodeToCode( buffer, &tmp );
		if(e==RESULT_FAILURE){
			nRetVal=RESULT_FAILURE;
			ErrorMessage(
				CEditWnd::getInstance()->GetHwnd(),
				LS(STR_FILESAVE_CONVERT_ERROR),
				sSaveInfo.cFilePath.c_str()
			);
			return nRetVal;
		}
	}


	try
	{
		//ファイルオープン
		CBinaryOutputStream out(sSaveInfo.cFilePath,true);

		//各行出力
		int			nLineNumber = 0;
		const CDocLine*	pcDocLine = pcDocLineMgr.GetDocLineTop();
		// 1行目
		{
			++nLineNumber;
			CMemory cmemOutputBuffer;
			{
				CNativeW cstrSrc;
				CMemory cstrBomCheck;
				pcCodeBase->GetBom( &cstrBomCheck );
				if( sSaveInfo.bBomExist && 0 < cstrBomCheck.GetRawLength() ){
					// 1行目にはBOMを付加する。エンコーダでbomがある場合のみ付加する。
					CUnicode().GetBom( cstrSrc._GetMemory() );
				}
				if( pcDocLine ){
					cstrSrc.AppendNativeData( pcDocLine->_GetDocLineDataWithEOL() );
				}
				EConvertResult e = pcCodeBase->UnicodeToCode( cstrSrc, &cmemOutputBuffer );
				if(e==RESULT_LOSESOME){
					nRetVal=RESULT_LOSESOME;
				}
				if(e==RESULT_FAILURE){
					nRetVal=RESULT_FAILURE;
					ErrorMessage(
						CEditWnd::getInstance()->GetHwnd(),
						LS(STR_FILESAVE_CONVERT_ERROR),
						sSaveInfo.cFilePath.c_str()
					);
					throw CError_FileWrite();
				}
			}
			out.Write(cmemOutputBuffer.GetRawPtr(), cmemOutputBuffer.GetRawLength());
			if( pcDocLine ){
				pcDocLine = pcDocLine->GetNextLine();
			}
		}
		CMemory cmemOutputBuffer;
		while( pcDocLine ){
			++nLineNumber;

			//経過通知
			if(pcDocLineMgr.GetLineCount()>0 && nLineNumber%1024==0){
				NotifyProgress(nLineNumber * 100 / pcDocLineMgr.GetLineCount());
				// 処理中のユーザー操作を可能にする
				if( !::BlockingHook( NULL ) ){
					throw CAppExitException(); //中断検出
				}
			}

			//1行出力 -> cmemOutputBuffer
			{
				// 書き込み時のコード変換 cstrSrc -> cmemOutputBuffer
				EConvertResult e = pcCodeBase->UnicodeToCode(
					pcDocLine->_GetDocLineDataWithEOL(),
					&cmemOutputBuffer
				);
				if(e==RESULT_LOSESOME){
					if(nRetVal==RESULT_COMPLETE)nRetVal=RESULT_LOSESOME;
				}
				if(e==RESULT_FAILURE){
					nRetVal=RESULT_FAILURE;
					ErrorMessage(
						CEditWnd::getInstance()->GetHwnd(),
						LS(STR_FILESAVE_CONVERT_ERROR),
						sSaveInfo.cFilePath.c_str()
					);
					break;
				}
			}

			//ファイルに出力 cmemOutputBuffer -> fp
			out.Write(cmemOutputBuffer.GetRawPtr(), cmemOutputBuffer.GetRawLength());

			//次の行へ
			pcDocLine = pcDocLine->GetNextLine();
		}

		//ファイルクローズ
		out.Close();
	}
	catch(CError_FileOpen){ //########### 現時点では、この例外が発生した場合は正常に動作できない
		ErrorMessage(
			CEditWnd::getInstance()->GetHwnd(),
			LS(STR_SAVEAGENT_OTHER_APP),
			sSaveInfo.cFilePath.c_str()
		);
		nRetVal = RESULT_FAILURE;
	}
	catch(CError_FileWrite){
		nRetVal = RESULT_FAILURE;
	}
	catch(CAppExitException){
		//中断検出
		return RESULT_FAILURE;
	}

	return nRetVal;
}
示例#15
0
void Builder::run()
{
    VLM_LatestError = BUILDER_NO_ERROR;
    //InterfaceArchiver * archives =new InterfaceArchiver();
    QString MCL_CurrentFilePath = "";
    int count;
    QFile VXL_UpdateListFile(VCM_OutputFilePath);
    QFileInfo VXL_UpdateListFileInfo;
    QDir VXL_UpdateListDir;
    //On vérirife l'existence du dossier
    VXL_UpdateListFileInfo.setFile(VXL_UpdateListFile);
    VXL_UpdateListDir = VXL_UpdateListFileInfo.absoluteDir();
    if(!VXL_UpdateListDir.exists())
    {
       VXL_UpdateListDir.mkpath(VXL_UpdateListFileInfo.absolutePath());
    }
    else
    {
        //On vérifie la présence du fichier
        if(VXL_UpdateListFile.exists())
        {
            //On le supprime
            VXL_UpdateListFile.remove();
        }
    }

    //On ouvre le fichier
    if (!VXL_UpdateListFile.open(QIODevice::WriteOnly | QIODevice::Text))
    {
            emit NotifyErrorMsg("Unable to open UpdateList File");
            VLM_LatestError = BUILDER_ERROR_CANT_OPEN_FILE;
            return;
    }
    //On créé le buffer pour insèrer du texte
    QTextStream VXL_OutTextStream(&VXL_UpdateListFile);
    count = OMM_ListFilesToTreate.size();
    VXL_OutTextStream << "[files]" <<"\n" << "fcount=" << count << "\n";
    for(int i=0; i<OMM_ListFilesToTreate.size();i++)
    {
        MCL_CurrentFilePath = 	OMM_ListFilesToTreate[i]->getPath() + "/"
                + OMM_ListFilesToTreate[i]->getFilename().section('/', -1);
        qDebug() << MCL_CurrentFilePath;
        //On calcul le hash du fichier
        OMM_ListFilesToTreate[i]->setSha1(CalcSha1(MCL_CurrentFilePath));

        //Si demandé, on affiche le fichier en cours de traitement
        #ifdef ENABLE_DEBUG_SHOWLISTS
            #ifdef QT_DEBUG
                    qDebug()    << "File :" << i+1 << "/" <<OMM_ListFilesToTreate.size()
                                << OMM_ListFilesToTreate[i]->getFilename() 	<< "|"
                                << OMM_ListFilesToTreate[i]->getpriority()	<< "|"
                                << OMM_ListFilesToTreate[i]->getPath()		<< "|"
                                << OMM_ListFilesToTreate[i]->getSha1() ;
            #endif //QT_DEBUG
        #endif //ENABLE_DEBUG_SHOWLISTS

        //On écris la ligne qui le concerne
        if(QString::compare(MCL_CurrentFilePath, VCM_ReferenceFilePath) == 0)
        {//Fichier de référence

        }
        else
        {//Fichier "normal"
                    count++;
            VXL_OutTextStream     << "F"<<i<<"="
            << OMM_ListFilesToTreate[i]->getFilename() 	<< "|"
            << OMM_ListFilesToTreate[i]->getSha1()		<< "|"
            << OMM_ListFilesToTreate[i]->getpriority()
            << "\n";
        }
        /***********TODO****************/
        QString fileToCopy(OMM_ListFilesToTreate[i]->getPath() + "/"
                           + OMM_ListFilesToTreate[i]->getFilename().section('/', -1));
        QString subPath(OMM_ListFilesToTreate[i]->getFilename().section('/', 0, -2));
        VXL_UpdateListDir.mkpath(subPath);
        QFile::copy(fileToCopy, VCM_ReferenceFilePath+OMM_ListFilesToTreate[i]->getFilename());
        // QFile::copy(OMM_ListFilesToTreate[i]->getFilename(),OMM_ListFilesToTreate[i]->getFilename());
        // On Maj la ProgressBar
        emit NotifyProgress(i+1,OMM_ListFilesToTreate.size());
    }
    return;
}
示例#16
0
void
RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
                                  const ImageMetadata& aMetadata,
                                  const DecoderTelemetry& aTelemetry,
                                  Progress aProgress,
                                  const IntRect& aInvalidRect,
                                  const Maybe<uint32_t>& aFrameCount,
                                  DecoderFlags aDecoderFlags,
                                  SurfaceFlags aSurfaceFlags)
{
  MOZ_ASSERT(NS_IsMainThread());

  // If the decoder detected an error, log it to the error console.
  if (aStatus.mShouldReportError && !aStatus.mWasAborted) {
    ReportDecoderError();
  }

  // Record all the metadata the decoder gathered about this image.
  bool metadataOK = SetMetadata(aMetadata, aStatus.mWasMetadataDecode);
  if (!metadataOK) {
    // This indicates a serious error that requires us to discard all existing
    // surfaces and redecode to recover. We'll drop the results from this
    // decoder on the floor, since they aren't valid.
    RecoverFromInvalidFrames(mSize,
                             FromSurfaceFlags(aSurfaceFlags));
    return;
  }

  MOZ_ASSERT(mError || mHasSize || !aMetadata.HasSize(),
             "SetMetadata should've gotten a size");

  if (!aStatus.mWasMetadataDecode && aStatus.mFinished && !aStatus.mWasAborted) {
    // Flag that we've been decoded before.
    mHasBeenDecoded = true;
  }

  // Send out any final notifications.
  NotifyProgress(aProgress, aInvalidRect, aFrameCount,
                 aDecoderFlags, aSurfaceFlags);

  if (!(aDecoderFlags & DecoderFlags::FIRST_FRAME_ONLY) &&
      mHasBeenDecoded && mAnimationState) {
    // We've finished a full decode of all animation frames and our AnimationState
    // has been notified about them all, so let it know not to expect anymore.
    mAnimationState->SetDoneDecoding(true);
  }

  if (!aStatus.mWasMetadataDecode && aTelemetry.mChunkCount) {
    Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS, aTelemetry.mChunkCount);
  }

  if (aStatus.mFinished) {
    // Do some telemetry if this isn't a metadata decode.
    if (!aStatus.mWasMetadataDecode) {
      Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
                            int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));

      if (aTelemetry.mSpeedHistogram) {
        Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
      }
    }

    // Detect errors.
    if (aStatus.mHadError && !aStatus.mWasAborted) {
      DoError();
    } else if (aStatus.mWasMetadataDecode && !mHasSize) {
      DoError();
    }

    // If we were waiting to fire the load event, go ahead and fire it now.
    if (mLoadProgress && aStatus.mWasMetadataDecode) {
      NotifyForLoadEvent(*mLoadProgress);
      mLoadProgress = Nothing();
      NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
    }
  }

  // If we were a metadata decode and a full decode was requested, do it.
  if (aStatus.mFinished && aStatus.mWasMetadataDecode && mWantFullDecode) {
    mWantFullDecode = false;
    RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
  }
}
示例#17
0
void CMirrorWorkThread::Run()
{
	::ZeroMemory( &m_report, sizeof(NBSYNC_REPORT) );
	m_report.nSize = sizeof(NBSYNC_REPORT);
	if ( m_nWorkType == NBSYNC_TYPE_REMIRROR && !m_bRebound )
	{
		try{
			Notify( NBSYNC_PHASE_REBIND );
			RebindMirror();
		}
		catch( CNDASException &e )
		{
			e.PrintStackTrace();
			// TODO : We need more detail... the reason.
			Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_MARK_BITMAP );
			return;
		}
	}

	if ( m_nWorkType == NBSYNC_TYPE_ADDMIRROR && !m_bAdded )
	{
		try {
			Notify( NBSYNC_PHASE_BIND );
			AddMirror();
		}
		catch( CNDASException &e )
		{
			e.PrintStackTrace();
			// TODO : We need more detail... the reason.
			Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_ADDMIRROR );
			return;
		}
	}

	CSession sSource, sDest;
	CBitmapSector bitmapSector;
	const UNIT_DISK_LOCATION *pSourceLocation, *pDestLocation;

	pSourceLocation = m_pSource->GetLocation()->GetUnitDiskLocation();
	pDestLocation	= m_pDest->GetLocation()->GetUnitDiskLocation();

	Notify( NBSYNC_PHASE_CONNECT );
	try{
		sSource.Connect( pSourceLocation->MACAddr );
		sDest.Connect( pDestLocation->MACAddr );
	}
	catch( CNDASException &e )
	{
		e.PrintStackTrace();
		Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_CONNECT );
		return;
	}

	try{
		sSource.Login( pSourceLocation->UnitNumber, TRUE );
		sDest.Login( pSourceLocation->UnitNumber, TRUE );
	}
	catch( CNDASException &e )
	{
		e.PrintStackTrace();
		Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_CONNECT );
		return;
	}

	Notify( NBSYNC_PHASE_RETRIVE_BITMAP );
	//
	// Get bitmap from the disk
	//
	try{
		bitmapSector.ReadAccept( &sSource );
	}
	catch( CNDASException &e )
	{
		e.PrintStackTrace();
		Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_READ_BITMAP );
		return;
	}

	Notify( NBSYNC_PHASE_SYNCHRONIZE );

	//
	// Copying blocks
	//
	CHDDDiskInfoHandler *pHandler;

	pHandler = dynamic_cast<CHDDDiskInfoHandler*>(m_pSource->GetInfoHandler().get());
	ATLASSERT( pHandler != NULL );

	int			i, j, k;
	_int8		bitFlag;
	_int16		nBitmapSecCount;
	_int32		nSectorPerBit, nSectorPerByte;
	_int8		*pbBitmap;
	_int64		nTotalDirtySize;
	_int64		nProcessedDirtySize;
	CDataSector dataSector, bitmapUpdateSector;

	pbBitmap = bitmapSector.GetData();
	nSectorPerBit = pHandler->GetSectorsPerBit();
	nSectorPerByte = nSectorPerBit*8;
	nBitmapSecCount = 
		static_cast<_int16>(
			pHandler->GetUserSectorCount() / (nSectorPerBit*BLOCK_SIZE*8)
			);
	ATLASSERT( nBitmapSecCount <= bitmapSector.GetCount() );
	dataSector.Resize(nSectorPerBit);
	::ZeroMemory( 
		bitmapUpdateSector.GetData(), 
		bitmapUpdateSector.GetCount() * BLOCK_SIZE 
		);
	// Calculate total amount of sectors to copy
	nTotalDirtySize = 0;
	nProcessedDirtySize = 0;
	for ( i=0; i < nBitmapSecCount; i++ )
	{
		for ( j=0; j < BLOCK_SIZE; j++ )
		{
			bitFlag = pbBitmap[i*BLOCK_SIZE + j];
			if ( bitFlag == 0x00 )	// flag is clean(since most flags can be clean, this can improve efficiency)
			{
				continue;
			}
			for ( k=0; k < sizeof(_int8)* 8; k++ )
			{
				if ( (bitFlag & ( 0x01 << k )) != 0 )
					nTotalDirtySize += nSectorPerBit;
			}
		}
	}
	NotifyTotalSize( 
		pHandler->GetUserSectorCount(),
		nTotalDirtySize );
	for ( i=0; i < nBitmapSecCount; i++ )
	{
		for ( j=0; j < BLOCK_SIZE; j++ )
		{
			bitFlag = pbBitmap[i*BLOCK_SIZE + j];
			if ( bitFlag == 0x00 )	// flag is clean(since most flags can be clean, this can improve efficiency)
			{
				continue;
			}

			for ( k=0; k < sizeof(_int8)* 8; k++ )
			{
				if ( IsStopped() )
				{
					goto out;
				}
				// Sectors are mapped from LSB to MSB
				if ( (bitFlag & ( 0x01 << k )) != 0 )
				{
					dataSector.SetLocation(
						(static_cast<_int64>(i*BLOCK_SIZE + j)*sizeof(_int8) + k)*nSectorPerBit
						);
					try {
						dataSector.ReadAccept( &sSource );
						dataSector.WriteAccept( &sDest );
					}
					catch( CNDASException &e )
					{
						e.PrintStackTrace();
						Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_COPY );
						return;
					}
					nProcessedDirtySize += nSectorPerBit;
				}
				NotifyProgressDirty( nProcessedDirtySize );
			} // for ( k=0; ...
		}	// for ( j=0; ...
		// Clean up bitmap
		if ( IsStopped() )
		{
			goto out;
		}
		bitmapUpdateSector.SetLocation( 
			bitmapSector.GetLocation() + static_cast<_int64>(i) 
			);
		try{
			bitmapUpdateSector.WriteAccept( &sSource );
		}
		catch( CNDASException &e )
		{
			e.PrintStackTrace();
			Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_UPDATE_BITMAP );
			return;
		}
		NotifyProgress( static_cast<_int64>(i*BLOCK_SIZE + j) * 8 * nSectorPerBit );
	}	// for ( i=0; ...

	// In case the bitmap does not fit into sectors exactly.
	_int64 nProcessedSize = 
		static_cast<_int64>(nBitmapSecCount) * BLOCK_SIZE * 8 * nSectorPerBit;
	if ( nProcessedSize < pHandler->GetUserSectorCount() )
	{
		int nLeftSize = 
			static_cast<int>(pHandler->GetUserSectorCount()-nProcessedSize);
		for ( i=0; i < nLeftSize; i++ )
		{
			bitFlag = pbBitmap[nBitmapSecCount*BLOCK_SIZE + i/nSectorPerByte];
			if ( IsStopped() )
			{
				goto out;
			}
			if ( (bitFlag & (0x01 << (i%8))) != 0 )
			{
				dataSector.SetLocation(
					static_cast<_int64>(nBitmapSecCount*BLOCK_SIZE + i)*nSectorPerBit
					);
				try {
					dataSector.ReadAccept( &sSource );
					dataSector.WriteAccept( &sDest );
				}
				catch( CNDASException &e )
				{
					e.PrintStackTrace();
					Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_COPY );
					return;
				}
				nProcessedDirtySize += nSectorPerBit;
				NotifyProgressDirty( nProcessedDirtySize );
			}
		}
		bitmapUpdateSector.SetLocation( 
			bitmapSector.GetLocation() + nBitmapSecCount
			);
		try{
			bitmapUpdateSector.WriteAccept( &sSource );
		}
		catch( CNDASException &e )
		{
			e.PrintStackTrace();
			Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_UPDATE_BITMAP );
			return;
		}
		NotifyProgress( pHandler->GetUserSectorCount() );
	}

	sSource.Logout();
	sDest.Logout();
	sSource.Disconnect();
	sDest.Disconnect();

	try{
		m_pSource->OpenExclusive();
		m_pSource->SetDirty(FALSE);
		m_pSource->CommitDiskInfo( TRUE );
	}
	catch( CNDASException &e )
	{
		e.PrintStackTrace();
		Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_FAIL_TO_CLEAR_DIRTYFLAG );
		return;
	}

	Notify( NBSYNC_PHASE_FINISHED );
	return;

out:
	sSource.Logout();
	sDest.Logout();
	sSource.Disconnect();
	sDest.Disconnect();
	
	if ( IsStopped() )
		Notify( NBSYNC_PHASE_FAILED, NBSYNC_ERRORCODE_STOPPED );
	else
		Notify( NBSYNC_PHASE_FINISHED );
}
示例#18
0
/*!
	現在の折り返し文字数に合わせて全データのレイアウト情報を再生成します

	@date 2004.04.03 Moca TABが使われると折り返し位置がずれるのを防ぐため,
		nPosXがインデントを含む幅を保持するように変更.m_nMaxLineKetasは
		固定値となったが,既存コードの置き換えは避けて最初に値を代入するようにした.
*/
void CLayoutMgr::_DoLayout(bool bBlockingHook)
{
	MY_RUNNINGTIMER( cRunningTimer, "CLayoutMgr::_DoLayout" );

	/*	表示上のX位置
		2004.03.28 Moca nPosXはインデント幅を含むように変更(TAB位置調整のため)
	*/
	int			nAllLineNum;

	if( GetListenerCount() != 0 ){
		NotifyProgress(0);
		/* 処理中のユーザー操作を可能にする */
		if( bBlockingHook ){
			if( !::BlockingHook( NULL ) )return;
		}
	}

	_Empty();
	Init();
	
	//	Nov. 16, 2002 genta
	//	折り返し幅 <= TAB幅のとき無限ループするのを避けるため,
	//	TABが折り返し幅以上の時はTAB=4としてしまう
	//	折り返し幅の最小値=10なのでこの値は問題ない
	if( GetTabSpace() >= GetMaxLineKetas() ){
		m_nTabSpace = CKetaXInt(4);
	}

	nAllLineNum = m_pcDocLineMgr->GetLineCount();

	SLayoutWork	_sWork;
	SLayoutWork* pWork = &_sWork;
	pWork->pcDocLine				= m_pcDocLineMgr->GetDocLineTop(); // 2002/2/10 aroka CDocLineMgr変更
	pWork->pLayout					= NULL;
	pWork->pcColorStrategy			= NULL;
	pWork->colorPrev				= COLORIDX_DEFAULT;
	pWork->nCurLine					= CLogicInt(0);

	while( NULL != pWork->pcDocLine ){
		pWork->cLineStr		= pWork->pcDocLine->GetStringRefWithEOL();
		pWork->eKinsokuType	= KINSOKU_TYPE_NONE;	//@@@ 2002.04.20 MIK
		pWork->nBgn			= CLogicInt(0);
		pWork->nPos			= CLogicInt(0);
		pWork->nWordBgn		= CLogicInt(0);
		pWork->nWordLen		= CLogicInt(0);
		pWork->nPosX		= CLayoutInt(0);	// 表示上のX位置
		pWork->nIndent		= CLayoutInt(0);	// インデント幅


		_MakeOneLine(pWork, &CLayoutMgr::_OnLine1);

		if( pWork->nPos - pWork->nBgn > 0 ){
// 2002/03/13 novice
			AddLineBottom( pWork->_CreateLayout(this) );
			pWork->colorPrev = pWork->pcColorStrategy->GetStrategyColorSafe();
			pWork->exInfoPrev.SetColorInfo(pWork->pcColorStrategy->GetStrategyColorInfoSafe());
		}

		// 次の行へ
		pWork->nCurLine++;
		pWork->pcDocLine = pWork->pcDocLine->GetNextLine();
		
		// 処理中のユーザー操作を可能にする
		if( GetListenerCount()!=0 && 0 < nAllLineNum && 0 == ( pWork->nCurLine % 1024 ) ){
			NotifyProgress(::MulDiv( pWork->nCurLine, 100 , nAllLineNum ) );
			if( bBlockingHook ){
				if( !::BlockingHook( NULL ) )return;
			}
		}

// 2002/03/13 novice
	}

	// 2011.12.31 Botの色分け情報は最後に設定
	m_nLineTypeBot = pWork->pcColorStrategy->GetStrategyColorSafe();
	m_cLayoutExInfoBot.SetColorInfo(pWork->pcColorStrategy->GetStrategyColorInfoSafe());

	m_nPrevReferLine = CLayoutInt(0);
	m_pLayoutPrevRefer = NULL;

	if( GetListenerCount()!=0 ){
		NotifyProgress(0);
		/* 処理中のユーザー操作を可能にする */
		if( bBlockingHook ){
			if( !::BlockingHook( NULL ) )return;
		}
	}
}
/*!
	ファイルを読み込んで格納する(分割読み込みテスト版)
	@version	2.0
	@note	Windows用にコーディングしてある
	@retval	TRUE	正常読み込み
	@retval	FALSE	エラー(またはユーザによるキャンセル?)
	@date	2002/08/30 Moca 旧ReadFileを元に作成 ファイルアクセスに関する部分をCFileLoadで行う
	@date	2003/07/26 ryoji BOMの状態の取得を追加
*/
EConvertResult CReadManager::ReadFile_To_CDocLineMgr(
	CDocLineMgr*		pcDocLineMgr,	//!< [out]
	const SLoadInfo&	sLoadInfo,		//!< [in]
	SFileInfo*			pFileInfo		//!< [out]
)
{
	LPCTSTR pszPath = sLoadInfo.cFilePath.c_str();

	// 文字コード種別
	const STypeConfigMini* type;
	CDocTypeManager().GetTypeConfigMini( sLoadInfo.nType, &type );
	ECodeType	eCharCode = sLoadInfo.eCharCode;
	if (CODE_AUTODETECT == eCharCode) {
		CCodeMediator cmediator( type->m_encoding );
		eCharCode = cmediator.CheckKanjiCodeOfFile( pszPath );
	}
	if (!IsValidCodeOrCPType( eCharCode )) {
		eCharCode = type->m_encoding.m_eDefaultCodetype;	// 2011.01.24 ryoji デフォルト文字コード
	}
	bool	bBom;
	if (eCharCode == type->m_encoding.m_eDefaultCodetype) {
		bBom = type->m_encoding.m_bDefaultBom;	// 2011.01.24 ryoji デフォルトBOM
	}
	else{
		bBom = CCodeTypeName( eCharCode ).IsBomDefOn();
	}
	pFileInfo->SetCodeSet( eCharCode, bBom );

	/* 既存データのクリア */
	pcDocLineMgr->DeleteAllLine();

	/* 処理中のユーザー操作を可能にする */
	if( !::BlockingHook( NULL ) ){
		return RESULT_FAILURE; //######INTERRUPT
	}

	EConvertResult eRet = RESULT_COMPLETE;

	try{
		CFileLoad cfl(type->m_encoding);

		bool bBigFile;
#ifdef _WIN64
		bBigFile = true;
#else
		bBigFile = false;
#endif
		// ファイルを開く
		// ファイルを閉じるにはFileCloseメンバ又はデストラクタのどちらかで処理できます
		//	Jul. 28, 2003 ryoji BOMパラメータ追加
		cfl.FileOpen( pszPath, bBigFile, eCharCode, GetDllShareData().m_Common.m_sFile.GetAutoMIMEdecode(), &bBom );
		pFileInfo->SetBomExist( bBom );

		/* ファイル時刻の取得 */
		FILETIME	FileTime;
		if( cfl.GetFileTime( NULL, NULL, &FileTime ) ){
			pFileInfo->SetFileTime( FileTime );
		}

		// ReadLineはファイルから 文字コード変換された1行を読み出します
		// エラー時はthrow CError_FileRead を投げます
		int				nLineNum = 0;
		CEol			cEol;
		CNativeW		cUnicodeBuffer;
		EConvertResult	eRead;
		while( RESULT_FAILURE != (eRead = cfl.ReadLine( &cUnicodeBuffer, &cEol )) ){
			if(eRead==RESULT_LOSESOME){
				eRet = RESULT_LOSESOME;
			}
			const wchar_t*	pLine = cUnicodeBuffer.GetStringPtr();
			int		nLineLen = cUnicodeBuffer.GetStringLength();
			++nLineNum;
			CDocEditAgent(pcDocLineMgr).AddLineStrX( pLine, nLineLen );
			//経過通知
			if(nLineNum%512==0){
				NotifyProgress(cfl.GetPercent());
				// 処理中のユーザー操作を可能にする
				if( !::BlockingHook( NULL ) ){
					throw CAppExitException(); //中断検出
				}
			}
		}

		// ファイルをクローズする
		cfl.FileClose();
	}
	catch(CAppExitException){
		//WM_QUITが発生した
		return RESULT_FAILURE;
	}
	catch( CError_FileOpen ){
		eRet = RESULT_FAILURE;
		if( !fexist( pszPath )){
			// ファイルがない
			ErrorMessage(
				CEditWnd::getInstance()->GetHwnd(),
				LS(STR_ERR_DLGDOCLM1),	//Mar. 24, 2001 jepro 若干修正
				pszPath
			);
		}
		else if( -1 == _taccess( pszPath, 4 )){
			// 読み込みアクセス権がない
			ErrorMessage(
				CEditWnd::getInstance()->GetHwnd(),
				LS(STR_ERR_DLGDOCLM2),
				pszPath
			 );
		}
		else{
			ErrorMessage(
				CEditWnd::getInstance()->GetHwnd(),
				LS(STR_ERR_DLGDOCLM3),
				pszPath
			 );
		}
	}
	catch( CError_FileRead ){
		eRet = RESULT_FAILURE;
		ErrorMessage(
			CEditWnd::getInstance()->GetHwnd(),
			LS(STR_ERR_DLGDOCLM4),
			pszPath
		 );
		/* 既存データのクリア */
		pcDocLineMgr->DeleteAllLine();
	} // 例外処理終わり

	NotifyProgress(0);
	/* 処理中のユーザー操作を可能にする */
	if( !::BlockingHook( NULL ) ){
		return RESULT_FAILURE; //####INTERRUPT
	}

	/* 行変更状態をすべてリセット */
//	CModifyVisitor().ResetAllModifyFlag(pcDocLineMgr, 0);
	return eRet;
}